#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*/ get;
typedef int /*<<< orphan*/ defstr;

/* Variables and functions */
int /*<<< orphan*/ GetPrivateProfileString(char const *, char const *, char *,
                                           char *, int, char const *);
int /*<<< orphan*/ memset(char *, int, int);
int /*<<< orphan*/ sprintf(char *, char *, int const);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int GetPrivateProfileInt(const char *section, const char *var, const int def,
                         const char *filename) {
  char get[10];
  char defstr[10];
  int res;
  memset(get, 0x00, sizeof(get));
  memset(defstr, 0x00, sizeof(defstr));
  if (!filename)
    return def;
  sprintf(defstr, "%d", def);
  GetPrivateProfileString(section, var, defstr, get, 10, filename);
  sscanf(get, "%d", &res);
  return res;
}


x86 assembly (clang, -O0):
<GetPrivateProfileInt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
lea    -0x32(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <memset@plt>
lea    -0x3c(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <memset@plt>
cmpq   $0x0,-0x28(%rbp)
jne    118d <GetPrivateProfileInt+0x4d>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11d9 <GetPrivateProfileInt+0x99>
lea    -0x3c(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xe65(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x3c(%rbp),%rdx
lea    -0x32(%rbp),%rcx
mov    -0x28(%rbp),%r9
mov    $0xa,%r8d
call   1030 <GetPrivateProfileString@plt>
lea    -0x32(%rbp),%rdi
lea    0xe36(%rip),%rsi
lea    -0x40(%rbp),%rdx
call   1050 <sscanf@plt>
mov    -0x40(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetPrivateProfileInt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%rbx
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xe(%rsp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <memset@plt>
lea    0x4(%rsp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <memset@plt>
test   %rbx,%rbx
je     11c9 <GetPrivateProfileInt+0x89>
lea    0xe79(%rip),%r12
lea    0x4(%rsp),%r13
mov    %r13,%rdi
mov    %r12,%rsi
mov    %ebp,%edx
call   1060 <sprintf@plt>
lea    0xe(%rsp),%rbp
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r13,%rdx
mov    %rbp,%rcx
mov    $0xa,%r8d
mov    %rbx,%r9
call   1030 <GetPrivateProfileString@plt>
mov    %rsp,%rdx
mov    %rbp,%rdi
mov    %r12,%rsi
call   1050 <sscanf@plt>
mov    (%rsp),%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @GetPrivateProfileInt(i8* %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca [10 x i8]
%11 = alloca [10 x i8]
%12 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i8* %3, i8** %9
%13 = getelementptr inbounds [10 x i8], [10 x i8]* %10, i64 0, i64 0
%14 = call i32 @memset(i8* %13, i32 0, i32 10)
%15 = getelementptr inbounds [10 x i8], [10 x i8]* %11, i64 0, i64 0
%16 = call i32 @memset(i8* %15, i32 0, i32 10)
%17 = load i8*, i8** %9
%18 = icmp ne i8* %17, null
br i1 %18, label %21, label %19
19: ; preds = %4
%20 = load i32, i32* %8
store i32 %20, i32* %5
br label %34
21: ; preds = %4
%22 = getelementptr inbounds [10 x i8], [10 x i8]* %11, i64 0, i64 0
%23 = load i32, i32* %8
%24 = call i32 @sprintf(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = load i8*, i8** %6
%26 = load i8*, i8** %7
%27 = getelementptr inbounds [10 x i8], [10 x i8]* %11, i64 0, i64 0
%28 = getelementptr inbounds [10 x i8], [10 x i8]* %10, i64 0, i64 0
%29 = load i8*, i8** %9
%30 = call i32 @GetPrivateProfileString(i8* %25, i8* %26, i8* %27, i8* %28, i32 10, i8* %29)
%31 = getelementptr inbounds [10 x i8], [10 x i8]* %10, i64 0, i64 0
%32 = call i32 @sscanf(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %12)
%33 = load i32, i32* %12
store i32 %33, i32* %5
br label %34
34: ; preds = %21, %19
%35 = load i32, i32* %5
ret i32 %35
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @GetPrivateProfileInt(i8* %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca [10 x i8]
%6 = alloca [10 x i8]
%7 = alloca i32
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%9 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%10 = bitcast i32* %7 to i8*
%11 = call i32 @memset(i8* %8, i32 0, i32 10)
%12 = call i32 @memset(i8* %9, i32 0, i32 10)
%13 = icmp eq i8* %3, null
br i1 %13, label %19, label %14
14: ; preds = %4
%15 = call i32 @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %2)
%16 = call i32 @GetPrivateProfileString(i8* %0, i8* %1, i8* %9, i8* %8, i32 10, i8* %3)
%17 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
%18 = load i32, i32* %7
br label %19
19: ; preds = %4, %14
%20 = phi i32 [ %18, %14 ], [ %2, %4 ]
ret i32 %20
}