#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 */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ settings_getInt(char *, int /*<<< orphan*/);
char *settings_getString(char *, char *);
int /*<<< orphan*/ settings_init(char *, int);
int /*<<< orphan*/ settings_setInt(char *, scalar_t__);
int main(int argc, char *argv[]) {
  settings_init("test.db", (argc < 2));
  settings_setInt("counter", settings_getInt("counter", 0) + 1);
  printf("%s\n", settings_getString("counter", "empty"));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xe87(%rip),%rdi
call   1050 <settings_init@plt>
lea    0xe83(%rip),%rdi
xor    %esi,%esi
call   1070 <settings_getInt@plt>
mov    %rax,%rsi
add    $0x1,%rsi
lea    0xe6e(%rip),%rdi
call   1030 <settings_setInt@plt>
lea    0xe62(%rip),%rdi
lea    0xe67(%rip),%rsi
call   1060 <settings_getString@plt>
mov    %rax,%rsi
lea    0xe54(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %esi,%esi
cmp    $0x2,%edi
setl   %sil
lea    0xe9f(%rip),%rdi
call   1050 <settings_init@plt>
lea    0xe9b(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1070 <settings_getInt@plt>
lea    0x1(%rax),%rsi
mov    %rbx,%rdi
call   1030 <settings_setInt@plt>
lea    0xe8a(%rip),%rsi
mov    %rbx,%rdi
call   1060 <settings_getString@plt>
lea    0xe77(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"test.db\00"
@.str.1 = [8 x i8] c"counter\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [6 x i8] c"empty\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 2
%8 = zext i1 %7 to i32
%9 = call i32 @settings_init(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = call i64 @settings_getInt(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 0)
%11 = add nsw i64 %10, 1
%12 = call i32 @settings_setInt(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i64 %11)
%13 = call i8* @settings_getString(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %13)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"test.db\00"
@.str.1 = [8 x i8] c"counter\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [6 x i8] c"empty\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = icmp slt i32 %0, 2
%4 = zext i1 %3 to i32
%5 = tail call i32 @settings_init(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = tail call i64 @settings_getInt(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 0)
%7 = add nsw i64 %6, 1
%8 = tail call i32 @settings_setInt(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i64 %7)
%9 = tail call i8* @settings_getString(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%10 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %9)
ret i32 0
}