#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*/ api_cmdline(char *, int);
int /*<<< orphan*/ api_end();
int /*<<< orphan*/ api_putstr0(char *);
int getnum(char **, int);
int /*<<< orphan*/ sprintf(char *, char *, int, int);
void HariMain(void) {
  int i;
  char s[30], *p;
  api_cmdline(s, 30);
  for (p = s; *p > ' '; p++) {
  }
  i = getnum(&p, 9);
  if (i == -0x7fffffff) {
    api_putstr0("error!\n");
  } else {
    sprintf(s, "= %d = 0x%x\n", i, i);
    api_putstr0(s);
  }
  api_end();
}


x86 assembly (clang, -O0):
<HariMain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    -0x30(%rbp),%rdi
mov    $0x1e,%esi
call   1050 <api_cmdline@plt>
lea    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jle    1194 <HariMain+0x44>
jmp    1183 <HariMain+0x33>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    116e <HariMain+0x1e>
lea    -0x38(%rbp),%rdi
mov    $0x9,%esi
call   1030 <getnum@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x80000001,-0x4(%rbp)
jne    11c3 <HariMain+0x73>
lea    0xe47(%rip),%rdi
call   1060 <api_putstr0@plt>
jmp    11e2 <HariMain+0x92>
lea    -0x30(%rbp),%rdi
mov    -0x4(%rbp),%edx
mov    -0x4(%rbp),%ecx
lea    0xe34(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x30(%rbp),%rdi
call   1060 <api_putstr0@plt>
mov    $0x0,%al
call   1040 <api_end@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HariMain>:
push   %rbx
sub    $0x30,%rsp
lea    0x10(%rsp),%rdi
mov    $0x1e,%esi
call   1050 <api_cmdline@plt>
lea    0xf(%rsp),%rax
nopl   0x0(%rax)
cmpb   $0x20,0x1(%rax)
lea    0x1(%rax),%rax
jg     1170 <HariMain+0x20>
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdi
mov    $0x9,%esi
call   1030 <getnum@plt>
cmp    $0x80000001,%eax
jne    119e <HariMain+0x4e>
lea    0xe64(%rip),%rdi
jmp    11b9 <HariMain+0x69>
lea    0xe63(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %eax,%edx
mov    %eax,%ecx
call   1070 <sprintf@plt>
mov    %rbx,%rdi
call   1060 <api_putstr0@plt>
xor    %eax,%eax
call   1040 <api_end@plt>
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"error!\0A\00"
@.str.1 = [13 x i8] c"= %d = 0x%x\0A\00"
define void @HariMain() {
%1 = alloca i32
%2 = alloca [30 x i8]
%3 = alloca i8*
%4 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%5 = call i32 @api_cmdline(i8* %4, i32 30)
%6 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
store i8* %6, i8** %3
br label %7
7: ; preds = %13, %0
%8 = load i8*, i8** %3
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp sgt i32 %10, 32
br i1 %11, label %12, label %16
12: ; preds = %7
br label %13
13: ; preds = %12
%14 = load i8*, i8** %3
%15 = getelementptr inbounds i8, i8* %14, i32 1
store i8* %15, i8** %3
br label %7
16: ; preds = %7
%17 = call i32 @getnum(i8** %3, i32 9)
store i32 %17, i32* %1
%18 = load i32, i32* %1
%19 = icmp eq i32 %18, -2147483647
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 @api_putstr0(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %29
22: ; preds = %16
%23 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%24 = load i32, i32* %1
%25 = load i32, i32* %1
%26 = call i32 @sprintf(i8* %23, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %24, i32 %25)
%27 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%28 = call i32 @api_putstr0(i8* %27)
br label %29
29: ; preds = %22, %20
%30 = call i32 (...) @api_end()
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"error!\0A\00"
@.str.1 = [13 x i8] c"= %d = 0x%x\0A\00"
define void @HariMain() {
%1 = alloca [30 x i8]
%2 = alloca i8*
%3 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%4 = bitcast i8** %2 to i8*
%5 = call i32 @api_cmdline(i8* %3, i32 30)
br label %6
6: ; preds = %6, %0
%7 = phi i8* [ %3, %0 ], [ %10, %6 ]
%8 = load i8, i8* %7
%9 = icmp sgt i8 %8, 32
%10 = getelementptr inbounds i8, i8* %7, i64 1
br i1 %9, label %6, label %11
11: ; preds = %6
store i8* %7, i8** %2
%12 = call i32 @getnum(i8** %2, i32 9)
%13 = icmp eq i32 %12, -2147483647
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 @api_putstr0(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %19
16: ; preds = %11
%17 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %12, i32 %12)
%18 = call i32 @api_putstr0(i8* %3)
br label %19
19: ; preds = %16, %14
%20 = call i32 (...) @api_end()
ret void
}