#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*/ getString(char *, int);
int /*<<< orphan*/ isdigit(char);
int getInt(int *num, const int size) {
  int i = 0, n = 0;
  char buffer[100];
  getString(buffer, 100);
  while (buffer[i] != '\n') {
    if (!isdigit(buffer[i]))
      return 0;
    n = n * 10;
    n += buffer[i] - '0';
    i++;
  }
  *num = n;
  return 1;
}


x86 assembly (clang, -O0):
<getInt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    -0x80(%rbp),%rdi
mov    $0x64,%esi
call   1030 <getString@plt>
movslq -0x18(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%eax
cmp    $0xa,%eax
je     11aa <getInt+0x8a>
movslq -0x18(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%edi
call   1040 <isdigit@plt>
cmp    $0x0,%eax
jne    1183 <getInt+0x63>
movl   $0x0,-0x4(%rbp)
jmp    11ba <getInt+0x9a>
imul   $0xa,-0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movslq -0x18(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%eax
sub    $0x30,%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114e <getInt+0x2e>
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getInt>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x68,%rsp
mov    %rdi,%r14
mov    %rsp,%rdi
mov    $0x64,%esi
call   1030 <getString@plt>
mov    (%rsp),%al
xor    %ebp,%ebp
cmp    $0xa,%al
je     1175 <getInt+0x55>
lea    0x1(%rsp),%rbx
xor    %r15d,%r15d
xor    %ebp,%ebp
nopl   (%rax)
movsbl %al,%edi
call   1040 <isdigit@plt>
test   %eax,%eax
je     117e <getInt+0x5e>
lea    0x0(%rbp,%rbp,4),%eax
movsbl -0x1(%rbx),%ecx
lea    (%rcx,%rax,2),%ebp
add    $0xffffffd0,%ebp
movzbl (%rbx),%eax
add    $0x1,%rbx
cmp    $0xa,%al
jne    1150 <getInt+0x30>
mov    %ebp,(%r14)
mov    $0x1,%r15d
mov    %r15d,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @getInt(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [100 x i8]
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%10 = call i32 @getString(i8* %9, i32 100)
br label %11
11: ; preds = %26, %2
%12 = load i32, i32* %6
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 10
br i1 %17, label %18, label %39
18: ; preds = %11
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = call i32 @isdigit(i8 signext %22)
%24 = icmp ne i32 %23, 0
br i1 %24, label %26, label %25
25: ; preds = %18
store i32 0, i32* %3
br label %42
26: ; preds = %18
%27 = load i32, i32* %7
%28 = mul nsw i32 %27, 10
store i32 %28, i32* %7
%29 = load i32, i32* %6
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = sub nsw i32 %33, 48
%35 = load i32, i32* %7
%36 = add nsw i32 %35, %34
store i32 %36, i32* %7
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 1
store i32 %38, i32* %6
br label %11
39: ; preds = %11
%40 = load i32, i32* %7
%41 = load i32*, i32** %4
store i32 %40, i32* %41
store i32 1, i32* %3
br label %42
42: ; preds = %39, %25
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
define i32 @getInt(i32* nocapture writeonly %0, i32 %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = call i32 @getString(i8* %4, i32 100)
%6 = load i8, i8* %4
%7 = icmp eq i8 %6, 10
br i1 %7, label %25, label %8
8: ; preds = %2, %15
%9 = phi i64 [ %21, %15 ], [ 0, %2 ]
%10 = phi i8 [ %23, %15 ], [ %6, %2 ]
%11 = phi i8* [ %22, %15 ], [ %4, %2 ]
%12 = phi i32 [ %20, %15 ], [ 0, %2 ]
%13 = call i32 @isdigit(i8 signext %10)
%14 = icmp eq i32 %13, 0
br i1 %14, label %27, label %15
15: ; preds = %8
%16 = mul nsw i32 %12, 10
%17 = load i8, i8* %11
%18 = sext i8 %17 to i32
%19 = add i32 %16, -48
%20 = add i32 %19, %18
%21 = add nuw i64 %9, 1
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 10
br i1 %24, label %25, label %8
25: ; preds = %15, %2
%26 = phi i32 [ 0, %2 ], [ %20, %15 ]
store i32 %26, i32* %0
br label %27
27: ; preds = %8, %25
%28 = phi i32 [ 1, %25 ], [ 0, %8 ]
ret i32 %28
}