signed int getint(struct _IO_FILE$link40 *dfile) {
  char ch[256l];
  signed int i;
  signed int num = 0;
  while (num == 0) {
    fscanf(dfile, "%s", (const void *)ch);
    while ((signed int)ch[0l] == 35)
      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    11c2 <getint+0x92>
mov    -0x8(%rbp),%rdi
lea    -0x110(%rbp),%rdx
lea    0xe98(%rip),%rsi
mov    $0x0,%al
call   1030 <fscanf@plt>
movsbl -0x110(%rbp),%eax
cmp    $0x23,%eax
jne    119b <getint+0x6b>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x100,%esi
mov    $0x0,%al
call   1040 <fgets@plt>
jmp    116f <getint+0x3f>
lea    -0x110(%rbp),%rdi
lea    0xe5a(%rip),%rsi
lea    -0x114(%rbp),%rdx
mov    $0x0,%al
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    1174 <getint+0x44>
nopl   (%rax)
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1050 <sscanf@plt>
test   %eax,%eax
jne    11ab <getint+0x7b>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1030 <fscanf@plt>
cmpb   $0x23,0x10(%rsp)
jne    1160 <getint+0x30>
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    $0x100,%esi
mov    %rbx,%rdx
xor    %eax,%eax
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):
%"struct._IO_FILE$link40" = type opaque
@.str = [3 x i8] c"%s\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @getint(%"struct._IO_FILE$link40"* %0) {
%2 = alloca %"struct._IO_FILE$link40"*
%3 = alloca [256 x i8]
%4 = alloca i32
%5 = alloca i32
store %"struct._IO_FILE$link40"* %0, %"struct._IO_FILE$link40"** %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 %"struct._IO_FILE$link40"*, %"struct._IO_FILE$link40"** %2
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%12 = call i32 (%"struct._IO_FILE$link40"*, i8*, i8*, ...) bitcast (i32 (...)* @fscanf to i32 (%"struct._IO_FILE$link40"*, i8*, i8*, ...)*)(%"struct._IO_FILE$link40"* %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 %"struct._IO_FILE$link40"*, %"struct._IO_FILE$link40"** %2
%21 = call i32 (i8*, i32, %"struct._IO_FILE$link40"*, ...) bitcast (i32 (...)* @fgets to i32 (i8*, i32, %"struct._IO_FILE$link40"*, ...)*)(i8* %19, i32 256, %"struct._IO_FILE$link40"* %20)
br label %13
22: ; preds = %13
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%24 = call i32 (i8*, i8*, ...) @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):
%"struct._IO_FILE$link40" = type opaque
@.str = [3 x i8] c"%s\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @getint(%"struct._IO_FILE$link40"* %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 (%"struct._IO_FILE$link40"*, i8*, i8*, ...) bitcast (i32 (...)* @fscanf to i32 (%"struct._IO_FILE$link40"*, i8*, i8*, ...)*)(%"struct._IO_FILE$link40"* %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 (i8*, i32, %"struct._IO_FILE$link40"*, ...) bitcast (i32 (...)* @fgets to i32 (i8*, i32, %"struct._IO_FILE$link40"*, ...)*)(i8* %4, i32 256, %"struct._IO_FILE$link40"* %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 (i8*, i8*, ...) @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
}