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

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int 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) {
    if (fscanf(dfile, "%s", ch) == 1) {
      while (ch[0] == '#') {
        fgets(ch, sizeof(ch), 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    11cf <getint+0x9f>
mov    -0x8(%rbp),%rdi
lea    -0x110(%rbp),%rdx
lea    0xe98(%rip),%rsi
call   1030 <fscanf@plt>
cmp    $0x1,%eax
jne    11aa <getint+0x7a>
jmp    117b <getint+0x4b>
movsbl -0x110(%rbp),%eax
cmp    $0x23,%eax
jne    11a5 <getint+0x75>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x100,%esi
call   1040 <fgets@plt>
jmp    117b <getint+0x4b>
jmp    11aa <getint+0x7a>
lea    -0x110(%rbp),%rdi
lea    0xe4b(%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    11b0 <getint+0x80>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1030 <fscanf@plt>
cmp    $0x1,%eax
jne    1160 <getint+0x30>
cs nopw 0x0(%rax,%rax,1)
nop
cmpb   $0x23,0x10(%rsp)
jne    1160 <getint+0x30>
mov    %r15,%rdi
mov    $0x100,%esi
mov    %rbx,%rdx
call   1040 <fgets@plt>
cmpb   $0x23,0x10(%rsp)
je     1197 <getint+0x67>
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 = %25, %1
%7 = load i32, i32* %5
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %28
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)
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %25
14: ; preds = %9
br label %15
15: ; preds = %20, %14
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 35
br i1 %19, label %20, label %24
20: ; preds = %15
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%22 = load i32*, i32** %2
%23 = call i32 @fgets(i8* %21, i32 256, i32* %22)
br label %15
24: ; preds = %15
br label %25
25: ; preds = %24, %9
%26 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%27 = call i32 @sscanf(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
store i32 %27, i32* %5
br label %6
28: ; preds = %6
%29 = load i32, i32* %4
ret i32 %29
}

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, %16
%7 = call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
%8 = icmp eq i32 %7, 1
%9 = load i8, i8* %4
%10 = icmp eq i8 %9, 35
%11 = select i1 %8, i1 %10, i1 false
br i1 %11, label %12, label %16
12: ; preds = %6, %12
%13 = call i32 @fgets(i8* %4, i32 256, i32* %0)
%14 = load i8, i8* %4
%15 = icmp eq i8 %14, 35
br i1 %15, label %12, label %16
16: ; preds = %12, %6
%17 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%18 = icmp eq i32 %17, 0
br i1 %18, label %6, label %19
19: ; preds = %16
%20 = load i32, i32* %3
ret i32 %20
}