#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*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int /*<<< orphan*/ system(char *);
int config(int callKeygen) {
  FILE *fp;
  char buf[10];
  fp = fopen(".config", "r");
  while (fgets(buf, 1024, fp)) {
    sscanf(buf, "%d", &callKeygen);
  }
  if (callKeygen == 0)
    system("echo 1 | tee .config > /dev/null");
  fclose(fp);
  return callKeygen;
}


x86 assembly (clang, -O0):
<config>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
lea    0xe9e(%rip),%rdi
lea    0xe9f(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    -0x1a(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x400,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     11a7 <config+0x57>
lea    -0x1a(%rbp),%rdi
lea    0xe71(%rip),%rsi
lea    -0x4(%rbp),%rdx
call   1060 <sscanf@plt>
jmp    1172 <config+0x22>
cmpl   $0x0,-0x4(%rbp)
jne    11bd <config+0x6d>
lea    0xe55(%rip),%rdi
call   1040 <system@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<config>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebp
mov    %edi,0x8(%rsp)
lea    0xe99(%rip),%rdi
lea    0xe9a(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
lea    0xe(%rsp),%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11c7 <config+0x77>
lea    0xe76(%rip),%r14
lea    0xe(%rsp),%rbp
lea    0x8(%rsp),%r15
xchg   %ax,%ax
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1060 <sscanf@plt>
mov    %rbp,%rdi
mov    $0x400,%esi
mov    %rbx,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
jne    11a0 <config+0x50>
mov    0x8(%rsp),%ebp
test   %ebp,%ebp
jne    11d7 <config+0x87>
lea    0xe3b(%rip),%rdi
call   1040 <system@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    0x8(%rsp),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c".config\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [33 x i8] c"echo 1 | tee .config > /dev/null\00"
define i32 @config(i32 %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca [10 x i8]
store i32 %0, i32* %2
%5 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %3
br label %6
6: ; preds = %11, %1
%7 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%8 = load i32*, i32** %3
%9 = call i64 @fgets(i8* %7, i32 1024, i32* %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%13 = call i32 @sscanf(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
br label %6
14: ; preds = %6
%15 = load i32, i32* %2
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = call i32 @system(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
br label %19
19: ; preds = %17, %14
%20 = load i32*, i32** %3
%21 = call i32 @fclose(i32* %20)
%22 = load i32, i32* %2
ret i32 %22
}

LLVM IR (-O2):
@.str = [8 x i8] c".config\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [33 x i8] c"echo 1 | tee .config > /dev/null\00"
define i32 @config(i32 %0) {
%2 = alloca i32
%3 = alloca [10 x i8]
store i32 %0, i32* %2
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = call i64 @fgets(i8* %4, i32 1024, i32* %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %14, label %8
8: ; preds = %1, %8
%9 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%10 = call i64 @fgets(i8* %4, i32 1024, i32* %5)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %8
12: ; preds = %8
%13 = load i32, i32* %2
br label %14
14: ; preds = %12, %1
%15 = phi i32 [ %13, %12 ], [ %0, %1 ]
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = call i32 @system(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
br label %19
19: ; preds = %17, %14
%20 = call i32 @fclose(i32* %5)
%21 = load i32, i32* %2
ret i32 %21
}