#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ lcd_write(char);
scalar_t__ parse_string_expression(char *, char **);
scalar_t__ strlen(char *);
int /*<<< orphan*/ syntax_error_msg_with_arg(char *, int /*<<< orphan*/ *);
void cmd_write(char *args) {
  char *value;
  if (parse_string_expression(args, &value)) {
    if (strlen(value) > 0) {
      lcd_write(value[0]);
    } else {
      syntax_error_msg_with_arg("Invalid argument", NULL);
    }
  }
}


x86 assembly (clang, -O0):
<cmd_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <parse_string_expression@plt>
cmp    $0x0,%rax
je     119c <cmd_write+0x5c>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
jle    1187 <cmd_write+0x47>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <lcd_write@plt>
jmp    1197 <cmd_write+0x57>
lea    0xe72(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <syntax_error_msg_with_arg@plt>
jmp    119c <cmd_write+0x5c>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_write>:
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rsi
call   1050 <parse_string_expression@plt>
test   %rax,%rax
je     117e <cmd_write+0x3e>
mov    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
test   %rax,%rax
jle    1170 <cmd_write+0x30>
movsbl (%rbx),%edi
call   1040 <lcd_write@plt>
jmp    117e <cmd_write+0x3e>
lea    0xe89(%rip),%rdi
xor    %esi,%esi
call   1060 <syntax_error_msg_with_arg@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Invalid argument\00"
define void @cmd_write(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i64 @parse_string_expression(i8* %4, i8** %3)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %19
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = call i64 @strlen(i8* %8)
%10 = icmp sgt i64 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %7
%12 = load i8*, i8** %3
%13 = getelementptr inbounds i8, i8* %12, i64 0
%14 = load i8, i8* %13
%15 = call i32 @lcd_write(i8 signext %14)
br label %18
16: ; preds = %7
%17 = call i32 @syntax_error_msg_with_arg(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32* null)
br label %18
18: ; preds = %16, %11
br label %19
19: ; preds = %18, %1
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"Invalid argument\00"
define void @cmd_write(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = call i64 @parse_string_expression(i8* %0, i8** %2)
%5 = icmp eq i64 %4, 0
br i1 %5, label %15, label %6
6: ; preds = %1
%7 = load i8*, i8** %2
%8 = call i64 @strlen(i8* dereferenceable(1) %7)
%9 = icmp sgt i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = load i8, i8* %7
%12 = call i32 @lcd_write(i8 signext %11)
br label %15
13: ; preds = %6
%14 = call i32 @syntax_error_msg_with_arg(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32* null)
br label %15
15: ; preds = %10, %13, %1
ret void
}