#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*/ free(char *);
int /*<<< orphan*/ get_input(char *, int);
char *malloc(int);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int strlen(char *);
int get_input_int(int *error) {
  char *input = malloc(sizeof(char) * 11);
  get_input(input, 11);
  if (error != NULL) {
    int i = 0, len = strlen(input);
    *error = 0;
    for (i = 0; i < len; i++) {
      if ((*(input + i) >= '0' && *(input + i) <= '9') || *(input + i) == '-') {
        continue;
      }
      *error = i + 1;
      break;
    }
  }
  int result = 0;
  sscanf(input, "%d", &result);
  free(input);
  return result;
}


x86 assembly (clang, -O0):
<get_input_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0xb,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0xb,%esi
call   1070 <get_input@plt>
cmpq   $0x0,-0x8(%rbp)
je     121b <get_input_int+0xcb>
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1216 <get_input_int+0xc6>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x30,%eax
jl     11dd <get_input_int+0x8d>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x39,%eax
jle    11f2 <get_input_int+0xa2>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2d,%eax
jne    11f7 <get_input_int+0xa7>
jmp    1208 <get_input_int+0xb8>
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
jmp    1216 <get_input_int+0xc6>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a7 <get_input_int+0x57>
jmp    121b <get_input_int+0xcb>
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xdd3(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1060 <sscanf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_input_int>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0xb,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0xb,%esi
call   1070 <get_input@plt>
test   %r14,%r14
je     11b0 <get_input_int+0x60>
mov    %rbx,%rdi
call   1040 <strlen@plt>
movl   $0x0,(%r14)
test   %eax,%eax
jle    11b0 <get_input_int+0x60>
mov    %eax,%ecx
xor    %eax,%eax
jmp    1199 <get_input_int+0x49>
nop
add    $0x1,%rax
cmp    %rax,%rcx
je     11b0 <get_input_int+0x60>
movzbl (%rbx,%rax,1),%edx
cmp    $0x2d,%dl
je     1190 <get_input_int+0x40>
add    $0xd0,%dl
cmp    $0xa,%dl
jb     1190 <get_input_int+0x40>
add    $0x1,%eax
mov    %eax,(%r14)
movl   $0x0,0x4(%rsp)
lea    0xe41(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rbx,%rdi
call   1060 <sscanf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x4(%rsp),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @get_input_int(i32* %0) {
%2 = alloca i32*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %2
%7 = call i8* @malloc(i32 11)
store i8* %7, i8** %3
%8 = load i8*, i8** %3
%9 = call i32 @get_input(i8* %8, i32 11)
%10 = load i32*, i32** %2
%11 = icmp ne i32* %10, null
br i1 %11, label %12, label %53
12: ; preds = %1
store i32 0, i32* %4
%13 = load i8*, i8** %3
%14 = call i32 @strlen(i8* %13)
store i32 %14, i32* %5
%15 = load i32*, i32** %2
store i32 0, i32* %15
store i32 0, i32* %4
br label %16
16: ; preds = %49, %12
%17 = load i32, i32* %4
%18 = load i32, i32* %5
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %52
20: ; preds = %16
%21 = load i8*, i8** %3
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp sge i32 %26, 48
br i1 %27, label %28, label %36
28: ; preds = %20
%29 = load i8*, i8** %3
%30 = load i32, i32* %4
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp sle i32 %34, 57
br i1 %35, label %44, label %36
36: ; preds = %28, %20
%37 = load i8*, i8** %3
%38 = load i32, i32* %4
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %37, i64 %39
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 45
br i1 %43, label %44, label %45
44: ; preds = %36, %28
br label %49
45: ; preds = %36
%46 = load i32, i32* %4
%47 = add nsw i32 %46, 1
%48 = load i32*, i32** %2
store i32 %47, i32* %48
br label %52
49: ; preds = %44
%50 = load i32, i32* %4
%51 = add nsw i32 %50, 1
store i32 %51, i32* %4
br label %16
52: ; preds = %45, %16
br label %53
53: ; preds = %52, %1
store i32 0, i32* %6
%54 = load i8*, i8** %3
%55 = call i32 @sscanf(i8* %54, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%56 = load i8*, i8** %3
%57 = call i32 @free(i8* %56)
%58 = load i32, i32* %6
ret i32 %58
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @get_input_int(i32* writeonly %0) {
%2 = alloca i32
%3 = tail call dereferenceable_or_null(11) i8* @malloc(i32 11)
%4 = tail call i32 @get_input(i8* %3, i32 11)
%5 = icmp eq i32* %0, null
br i1 %5, label %25, label %6
6: ; preds = %1
%7 = tail call i32 @strlen(i8* %3)
store i32 0, i32* %0
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %25
9: ; preds = %6
%10 = zext i32 %7 to i64
br label %11
11: ; preds = %9, %22
%12 = phi i64 [ 0, %9 ], [ %23, %22 ]
%13 = getelementptr inbounds i8, i8* %3, i64 %12
%14 = load i8, i8* %13
%15 = add i8 %14, -48
%16 = icmp ult i8 %15, 10
%17 = icmp eq i8 %14, 45
%18 = or i1 %17, %16
br i1 %18, label %22, label %19
19: ; preds = %11
%20 = trunc i64 %12 to i32
%21 = add nuw nsw i32 %20, 1
store i32 %21, i32* %0
br label %25
22: ; preds = %11
%23 = add nuw nsw i64 %12, 1
%24 = icmp eq i64 %23, %10
br i1 %24, label %25, label %11
25: ; preds = %22, %6, %19, %1
%26 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%27 = call i32 @sscanf(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%28 = call i32 @free(i8* %3)
%29 = load i32, i32* %2
ret i32 %29
}