#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 atoi(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fscanf(int /*<<< orphan*/ *, char *, int *, char *);
int /*<<< orphan*/ hand(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int findPercent(int uid) {
  FILE *in;
  int percent = 100;
  char uid_local[10];
  if ((in = fopen("/etc/cpulim.conf", "r")) == NULL) {
    perror("Configuration file does not exist, create it (with \"100 0\")");
    hand(0);
  }
  while (!feof(in) && fscanf(in, "%d %s\n", &percent, uid_local) == 2)
    if (uid_local[0] == '*' || uid == atoi(uid_local)) {
      fclose(in);
      return percent;
    }
  return percent;
}


x86 assembly (clang, -O0):
<findPercent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x64,-0x14(%rbp)
lea    0xe77(%rip),%rdi
lea    0xe81(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    11b6 <findPercent+0x46>
lea    0xe69(%rip),%rdi
call   1080 <perror@plt>
xor    %edi,%edi
call   1040 <hand@plt>
jmp    11bb <findPercent+0x4b>
mov    -0x10(%rbp),%rdi
call   1060 <feof@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x1f(%rbp)
jne    11f5 <findPercent+0x85>
mov    -0x10(%rbp),%rdi
lea    -0x1e(%rbp),%rcx
lea    0xe6c(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1050 <fscanf@plt>
cmp    $0x2,%eax
sete   %al
mov    %al,-0x1f(%rbp)
mov    -0x1f(%rbp),%al
test   $0x1,%al
jne    1205 <findPercent+0x95>
jmp    1247 <findPercent+0xd7>
movsbl -0x1e(%rbp),%eax
cmp    $0x2a,%eax
je     122e <findPercent+0xbe>
mov    -0x8(%rbp),%eax
mov    %eax,-0x24(%rbp)
lea    -0x1e(%rbp),%rdi
call   1090 <atoi@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jne    1242 <findPercent+0xd2>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    124d <findPercent+0xdd>
jmp    11bb <findPercent+0x4b>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findPercent>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %edi,%r12d
movl   $0x64,(%rsp)
lea    0xe73(%rip),%rdi
lea    0xe7d(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11fe <findPercent+0x8e>
lea    0xea7(%rip),%r14
mov    %rsp,%r15
lea    0x6(%rsp),%rbp
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    11ee <findPercent+0x7e>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %rbp,%rcx
call   1050 <fscanf@plt>
cmp    $0x2,%eax
jne    11ee <findPercent+0x7e>
cmpb   $0x2a,0x6(%rsp)
je     11e6 <findPercent+0x76>
mov    %rbp,%rdi
call   1090 <atoi@plt>
cmp    %r12d,%eax
jne    11b0 <findPercent+0x40>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    (%rsp),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe0e(%rip),%rdi
call   1080 <perror@plt>
xor    %edi,%edi
call   1040 <hand@plt>
jmp    11a1 <findPercent+0x31>

LLVM IR (-O0):
@.str = [17 x i8] c"/etc/cpulim.conf\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [60 x i8] c"Configuration file does not exist, create it (with \22100 0\22)\00"
@.str.3 = [7 x i8] c"%d %s\0A\00"
define i32 @findPercent(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca [10 x i8]
store i32 %0, i32* %3
store i32 100, i32* %5
%7 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %4
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = call i32 @perror(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @hand(i32 0)
br label %12
12: ; preds = %9, %1
br label %13
13: ; preds = %38, %12
%14 = load i32*, i32** %4
%15 = call i32 @feof(i32* %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %22, label %17
17: ; preds = %13
%18 = load i32*, i32** %4
%19 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%20 = call i32 @fscanf(i32* %18, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32* %5, i8* %19)
%21 = icmp eq i32 %20, 2
br label %22
22: ; preds = %17, %13
%23 = phi i1 [ false, %13 ], [ %21, %17 ]
br i1 %23, label %24, label %39
24: ; preds = %22
%25 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 42
br i1 %28, label %34, label %29
29: ; preds = %24
%30 = load i32, i32* %3
%31 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%32 = call i32 @atoi(i8* %31)
%33 = icmp eq i32 %30, %32
br i1 %33, label %34, label %38
34: ; preds = %29, %24
%35 = load i32*, i32** %4
%36 = call i32 @fclose(i32* %35)
%37 = load i32, i32* %5
store i32 %37, i32* %2
br label %41
38: ; preds = %29
br label %13
39: ; preds = %22
%40 = load i32, i32* %5
store i32 %40, i32* %2
br label %41
41: ; preds = %39, %34
%42 = load i32, i32* %2
ret i32 %42
}

LLVM IR (-O2):
@.str = [17 x i8] c"/etc/cpulim.conf\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [60 x i8] c"Configuration file does not exist, create it (with \22100 0\22)\00"
@.str.3 = [7 x i8] c"%d %s\0A\00"
define i32 @findPercent(i32 %0) {
%2 = alloca i32
%3 = alloca [10 x i8]
%4 = bitcast i32* %2 to i8*
store i32 100, i32* %2
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%6 = tail call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = tail call i32 @perror(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.2, i64 0, i64 0))
%10 = tail call i32 @hand(i32 0)
br label %11
11: ; preds = %8, %1
br label %12
12: ; preds = %11, %21
%13 = call i32 @feof(i32* %6)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %26
15: ; preds = %12
%16 = call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32* %2, i8* %5)
%17 = icmp eq i32 %16, 2
br i1 %17, label %18, label %26
18: ; preds = %15
%19 = load i8, i8* %5
%20 = icmp eq i8 %19, 42
br i1 %20, label %24, label %21
21: ; preds = %18
%22 = call i32 @atoi(i8* %5)
%23 = icmp eq i32 %22, %0
br i1 %23, label %24, label %12
24: ; preds = %21, %18
%25 = call i32 @fclose(i32* %6)
br label %26
26: ; preds = %15, %12, %24
%27 = load i32, i32* %2
ret i32 %27
}