#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 EXIT_FAILURE;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ parse_and_print(int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char const *);
int /*<<< orphan*/ printf(char *, ...);
char *read_value_str(int /*<<< orphan*/ *, char *, char *, char *);
int main(int argc, char **argv) {
  const char *filename = "test.ini";
  FILE *fp = fopen(filename, "r");
  if (!fp) {
    perror(filename);
    return EXIT_FAILURE;
  }
  parse_and_print(fp);
  char buffer[140];
  char *ptr = read_value_str(fp, "Group1", "key2", buffer);
  if (ptr != NULL) {
    printf("Find value: %s\n", buffer);
  } else {
    printf("Can't find!\n");
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe80(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe7a(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11bd <main+0x5d>
mov    -0x18(%rbp),%rdi
call   1080 <perror@plt>
mov    0x2e2d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1231 <main+0xd1>
mov    -0x20(%rbp),%rdi
call   1030 <parse_and_print@plt>
mov    -0x20(%rbp),%rdi
lea    -0xb0(%rbp),%rcx
lea    0xe33(%rip),%rsi
lea    0xe33(%rip),%rdx
call   1040 <read_value_str@plt>
mov    %rax,-0xb8(%rbp)
cmpq   $0x0,-0xb8(%rbp)
je     1213 <main+0xb3>
lea    -0xb0(%rbp),%rsi
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1221 <main+0xc1>
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x90,%rsp
lea    0xe81(%rip),%rdi
lea    0xe83(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     11eb <main+0x7b>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <parse_and_print@plt>
lea    0xe69(%rip),%rsi
lea    0xe69(%rip),%rdx
mov    %rsp,%rcx
mov    %rbx,%rdi
call   1050 <read_value_str@plt>
test   %rax,%rax
je     11cc <main+0x5c>
lea    0xe57(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    11d8 <main+0x68>
lea    0xe54(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbx
ret
lea    0xe0e(%rip),%rdi
call   1090 <perror@plt>
mov    0x2de2(%rip),%rax
mov    (%rax),%eax
jmp    11e2 <main+0x72>

LLVM IR (-O0):
@.str = [9 x i8] c"test.ini\00"
@.str.1 = [2 x i8] c"r\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [7 x i8] c"Group1\00"
@.str.3 = [5 x i8] c"key2\00"
@.str.4 = [16 x i8] c"Find value: %s\0A\00"
@.str.5 = [13 x i8] c"Can't find!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca [140 x i8]
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8** %6
%10 = load i8*, i8** %6
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %11, i32** %7
%12 = load i32*, i32** %7
%13 = icmp ne i32* %12, null
br i1 %13, label %18, label %14
14: ; preds = %2
%15 = load i8*, i8** %6
%16 = call i32 @perror(i8* %15)
%17 = load i32, i32* @EXIT_FAILURE
store i32 %17, i32* %3
br label %34
18: ; preds = %2
%19 = load i32*, i32** %7
%20 = call i32 @parse_and_print(i32* %19)
%21 = load i32*, i32** %7
%22 = getelementptr inbounds [140 x i8], [140 x i8]* %8, i64 0, i64 0
%23 = call i8* @read_value_str(i32* %21, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %22)
store i8* %23, i8** %9
%24 = load i8*, i8** %9
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %29
26: ; preds = %18
%27 = getelementptr inbounds [140 x i8], [140 x i8]* %8, i64 0, i64 0
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8* %27)
br label %31
29: ; preds = %18
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
br label %31
31: ; preds = %29, %26
%32 = load i32*, i32** %7
%33 = call i32 @fclose(i32* %32)
store i32 0, i32* %3
br label %34
34: ; preds = %31, %14
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
@.str = [9 x i8] c"test.ini\00"
@.str.1 = [2 x i8] c"r\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [7 x i8] c"Group1\00"
@.str.3 = [5 x i8] c"key2\00"
@.str.4 = [16 x i8] c"Find value: %s\0A\00"
@str = [12 x i8] c"Can't find!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [140 x i8]
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 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 %6, label %9
6: ; preds = %2
%7 = tail call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @EXIT_FAILURE
br label %20
9: ; preds = %2
%10 = tail call i32 @parse_and_print(i32* %4)
%11 = getelementptr inbounds [140 x i8], [140 x i8]* %3, i64 0, i64 0
%12 = call i8* @read_value_str(i32* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %11)
%13 = icmp eq i8* %12, null
br i1 %13, label %16, label %14
14: ; preds = %9
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8* %11)
br label %18
16: ; preds = %9
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %18
18: ; preds = %16, %14
%19 = call i32 @fclose(i32* %4)
br label %20
20: ; preds = %18, %6
%21 = phi i32 [ 0, %18 ], [ %8, %6 ]
ret i32 %21
}