#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 */
scalar_t__ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ isspace(char);
int sscanf(char *, char *, int *, char *);
int /*<<< orphan*/ stdin;
int mygeti(int *result) {
  char c, buff[13];
  return fgets(buff, sizeof buff, stdin) && !isspace(*buff) &&
         sscanf(buff, "%d%c", result, &c) == 2 && (c == '\n' || c == '\0');
}


x86 assembly (clang, -O0):
<mygeti>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x16(%rbp),%rdi
mov    0x2ea1(%rip),%rax
mov    (%rax),%edx
mov    $0xd,%esi
call   1040 <fgets@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x17(%rbp)
je     11cb <mygeti+0x9b>
movsbl -0x16(%rbp),%edi
call   1030 <isspace@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x17(%rbp)
jne    11cb <mygeti+0x9b>
lea    -0x16(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe73(%rip),%rsi
lea    -0x9(%rbp),%rcx
call   1050 <sscanf@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x2,%ecx
mov    %al,-0x17(%rbp)
jne    11cb <mygeti+0x9b>
movsbl -0x9(%rbp),%ecx
mov    $0x1,%al
cmp    $0xa,%ecx
mov    %al,-0x18(%rbp)
je     11c5 <mygeti+0x95>
movsbl -0x9(%rbp),%eax
cmp    $0x0,%eax
sete   %al
mov    %al,-0x18(%rbp)
mov    -0x18(%rbp),%al
mov    %al,-0x17(%rbp)
mov    -0x17(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mygeti>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
mov    0x2ea7(%rip),%rax
mov    (%rax),%edx
lea    0xb(%rsp),%rdi
mov    $0xd,%esi
call   1040 <fgets@plt>
xor    %ebx,%ebx
test   %rax,%rax
je     1198 <mygeti+0x68>
movsbl 0xb(%rsp),%edi
call   1030 <isspace@plt>
test   %eax,%eax
jne    1198 <mygeti+0x68>
lea    0xe92(%rip),%rsi
lea    0xb(%rsp),%rdi
lea    0xa(%rsp),%rcx
mov    %r14,%rdx
call   1050 <sscanf@plt>
cmp    $0x2,%eax
jne    1198 <mygeti+0x68>
mov    0xa(%rsp),%al
cmp    $0xa,%al
sete   %cl
test   %al,%al
sete   %al
or     %cl,%al
movzbl %al,%ebx
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [5 x i8] c"%d%c\00"
define i32 @mygeti(i32* %0) {
%2 = alloca i32*
%3 = alloca i8
%4 = alloca [13 x i8]
store i32* %0, i32** %2
%5 = getelementptr inbounds [13 x i8], [13 x i8]* %4, i64 0, i64 0
%6 = load i32, i32* @stdin
%7 = call i64 @fgets(i8* %5, i32 13, i32 %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %29
9: ; preds = %1
%10 = getelementptr inbounds [13 x i8], [13 x i8]* %4, i64 0, i64 0
%11 = load i8, i8* %10
%12 = call i32 @isspace(i8 signext %11)
%13 = icmp ne i32 %12, 0
br i1 %13, label %29, label %14
14: ; preds = %9
%15 = getelementptr inbounds [13 x i8], [13 x i8]* %4, i64 0, i64 0
%16 = load i32*, i32** %2
%17 = call i32 @sscanf(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %16, i8* %3)
%18 = icmp eq i32 %17, 2
br i1 %18, label %19, label %29
19: ; preds = %14
%20 = load i8, i8* %3
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 10
br i1 %22, label %27, label %23
23: ; preds = %19
%24 = load i8, i8* %3
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 0
br label %27
27: ; preds = %23, %19
%28 = phi i1 [ true, %19 ], [ %26, %23 ]
br label %29
29: ; preds = %27, %14, %9, %1
%30 = phi i1 [ false, %14 ], [ false, %9 ], [ false, %1 ], [ %28, %27 ]
%31 = zext i1 %30 to i32
ret i32 %31
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [5 x i8] c"%d%c\00"
define i32 @mygeti(i32* %0) {
%2 = alloca i8
%3 = alloca [13 x i8]
%4 = getelementptr inbounds [13 x i8], [13 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* @stdin
%6 = call i64 @fgets(i8* %4, i32 13, i32 %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %21, label %8
8: ; preds = %1
%9 = load i8, i8* %4
%10 = call i32 @isspace(i8 signext %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %21
12: ; preds = %8
%13 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %0, i8* %2)
%14 = icmp eq i32 %13, 2
br i1 %14, label %15, label %21
15: ; preds = %12
%16 = load i8, i8* %2
%17 = icmp eq i8 %16, 10
%18 = icmp eq i8 %16, 0
%19 = or i1 %17, %18
%20 = zext i1 %19 to i32
br label %21
21: ; preds = %15, %12, %8, %1
%22 = phi i32 [ 0, %12 ], [ 0, %8 ], [ 0, %1 ], [ %20, %15 ]
ret i32 %22
}