#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 */
scalar_t__ next_line_str(int /*<<< orphan*/ *, char *, char *);
int sscanf(char *, char *, int *);
int next_line_int(FILE *f, char *tag, int *out) {
  char str[256];
  if (next_line_str(f, tag, str) && sscanf(str, "%d", out) == 1)
    return 1;
  else
    return 0;
}


x86 assembly (clang, -O0):
<next_line_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x120(%rbp),%rdx
call   1030 <next_line_str@plt>
cmp    $0x0,%rax
je     1181 <next_line_int+0x61>
lea    -0x120(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe99(%rip),%rsi
call   1040 <sscanf@plt>
cmp    $0x1,%eax
jne    1181 <next_line_int+0x61>
movl   $0x1,-0x4(%rbp)
jmp    1188 <next_line_int+0x68>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<next_line_int>:
push   %rbx
sub    $0x100,%rsp
mov    %rdx,%rbx
mov    %rsp,%rdx
call   1030 <next_line_str@plt>
test   %rax,%rax
je     1156 <next_line_int+0x36>
lea    0xec1(%rip),%rsi
mov    %rsp,%rdi
mov    %rbx,%rdx
call   1040 <sscanf@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    $0x1,%ecx
je     1158 <next_line_int+0x38>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @next_line_int(i32* %0, i8* %1, i32* %2) {
%4 = alloca [256 x i8]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%6 = call i64 @next_line_str(i32* %0, i8* %1, i8* %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %3
%9 = call i32 @sscanf(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%10 = icmp eq i32 %9, 1
br i1 %10, label %12, label %11
11: ; preds = %8, %3
br label %12
12: ; preds = %8, %11
%13 = phi i32 [ 0, %11 ], [ 1, %8 ]
ret i32 %13
}