#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *);
int sscanf(char *, char *, int *);
int getint(FILE *dfile) {
  char ch[256];
  int i;
  int num;
  num = 0;
  while (num == 0) {
    fscanf(dfile, "%s", ch);
    while (ch[0] == '#') {
      fgets(ch, 256, dfile);
    }
    num = sscanf(ch, "%d", &i);
  }
  return i;
}


x86 assembly (clang, -O0):
<getint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x118(%rbp)
cmpl   $0x0,-0x118(%rbp)
jne    11bc <getint+0x8c>
mov    -0x8(%rbp),%rdi
lea    -0x110(%rbp),%rdx
lea    0xe98(%rip),%rsi
call   1030 <fscanf@plt>
movsbl -0x110(%rbp),%eax
cmp    $0x23,%eax
jne    1197 <getint+0x67>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x100,%esi
call   1040 <fgets@plt>
jmp    116d <getint+0x3d>
lea    -0x110(%rbp),%rdi
lea    0xe5e(%rip),%rsi
lea    -0x114(%rbp),%rdx
call   1050 <sscanf@plt>
mov    %eax,-0x118(%rbp)
jmp    1149 <getint+0x19>
mov    -0x114(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getint>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x110,%rsp
mov    %rdi,%rbx
lea    0xeb6(%rip),%r14
lea    0x10(%rsp),%r15
lea    0xead(%rip),%r12
lea    0xc(%rsp),%r13
jmp    1172 <getint+0x42>
nopl   (%rax)
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1050 <sscanf@plt>
test   %eax,%eax
jne    11a9 <getint+0x79>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1030 <fscanf@plt>
cmpb   $0x23,0x10(%rsp)
jne    1160 <getint+0x30>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    $0x100,%esi
mov    %rbx,%rdx
call   1040 <fgets@plt>
cmpb   $0x23,0x10(%rsp)
je     1190 <getint+0x60>
jmp    1160 <getint+0x30>
mov    0xc(%rsp),%eax
add    $0x110,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @getint(i32* %0) {
%2 = alloca i32*
%3 = alloca [256 x i8]
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %5
br label %6
6: ; preds = %22, %1
%7 = load i32, i32* %5
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %25
9: ; preds = %6
%10 = load i32*, i32** %2
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%12 = call i32 @fscanf(i32* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %11)
br label %13
13: ; preds = %18, %9
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 35
br i1 %17, label %18, label %22
18: ; preds = %13
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%20 = load i32*, i32** %2
%21 = call i32 @fgets(i8* %19, i32 256, i32* %20)
br label %13
22: ; preds = %13
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%24 = call i32 @sscanf(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
store i32 %24, i32* %5
br label %6
25: ; preds = %6
%26 = load i32, i32* %4
ret i32 %26
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @getint(i32* nocapture %0) {
%2 = alloca [256 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%5 = bitcast i32* %3 to i8*
br label %6
6: ; preds = %1, %14
%7 = call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
%8 = load i8, i8* %4
%9 = icmp eq i8 %8, 35
br i1 %9, label %10, label %14
10: ; preds = %6, %10
%11 = call i32 @fgets(i8* %4, i32 256, i32* %0)
%12 = load i8, i8* %4
%13 = icmp eq i8 %12, 35
br i1 %13, label %10, label %14
14: ; preds = %10, %6
%15 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%16 = icmp eq i32 %15, 0
br i1 %16, label %6, label %17
17: ; preds = %14
%18 = load i32, i32* %3
ret i32 %18
}