#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *, int *, char *);
int get_input(char *value, int *base1, int *base2) {
  int err = 0;
  FILE *f_in;
  if ((f_in = fopen("in.txt", "r")) != NULL) {
    fscanf(f_in, "%i %i\n%s", base1, base2, value);
    fclose(f_in);
  } else {
    err = 1;
  }
  return err;
}


x86 assembly (clang, -O0):
<get_input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xeae(%rip),%rdi
lea    0xeae(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     1196 <get_input+0x66>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%r8
lea    0xe86(%rip),%rsi
call   1040 <fscanf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
jmp    119d <get_input+0x6d>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_input>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%r15
lea    0xeb8(%rip),%rdi
lea    0xeb8(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     1180 <get_input+0x50>
mov    %rax,%rbx
lea    0xea6(%rip),%rsi
mov    %rax,%rdi
mov    %r12,%rdx
mov    %r14,%rcx
mov    %r15,%r8
call   1040 <fscanf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
jmp    1185 <get_input+0x55>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"in.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [9 x i8] c"%i %i\0A%s\00"
define i32 @get_input(i8* %0, i32* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32*
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
store i32 0, i32* %7
%9 = call i32* @fopen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %8
%10 = icmp ne i32* %9, null
br i1 %10, label %11, label %19
11: ; preds = %3
%12 = load i32*, i32** %8
%13 = load i32*, i32** %5
%14 = load i32*, i32** %6
%15 = load i8*, i8** %4
%16 = call i32 @fscanf(i32* %12, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32* %13, i32* %14, i8* %15)
%17 = load i32*, i32** %8
%18 = call i32 @fclose(i32* %17)
br label %20
19: ; preds = %3
store i32 1, i32* %7
br label %20
20: ; preds = %19, %11
%21 = load i32, i32* %7
ret i32 %21
}

LLVM IR (-O2):
@.str = [7 x i8] c"in.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [9 x i8] c"%i %i\0A%s\00"
define i32 @get_input(i8* %0, i32* %1, i32* %2) {
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %9, label %6
6: ; preds = %3
%7 = tail call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32* %1, i32* %2, i8* %0)
%8 = tail call i32 @fclose(i32* %4)
br label %9
9: ; preds = %3, %6
%10 = phi i32 [ 0, %6 ], [ 1, %3 ]
ret i32 %10
}