#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 item_read(char *, char *, char *, int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int config_read(void) {
  int ret = 0;
  char key[1024] = {0};
  char value[1024] = {0};
  int len = 0;
  printf("input key:");
  scanf("%s", key);
  ret = item_read("./config.txt", key, value, &len);
  if (ret != 0) {
    printf("func read configure file err:%d\n", ret);
    return ret;
  }
  printf("your read item is:%s = %s\n", key, value);
  return ret;
}


x86 assembly (clang, -O0):
<config_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
movl   $0x0,-0x8(%rbp)
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
lea    -0x810(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
movl   $0x0,-0x814(%rbp)
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x410(%rbp),%rsi
lea    0xe6d(%rip),%rdi
call   1060 <scanf@plt>
lea    -0x410(%rbp),%rsi
lea    -0x810(%rbp),%rdx
lea    0xe56(%rip),%rdi
lea    -0x814(%rbp),%rcx
call   1040 <item_read@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11ed <config_read+0xad>
mov    -0x8(%rbp),%esi
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    120f <config_read+0xcf>
lea    -0x410(%rbp),%rsi
lea    -0x810(%rbp),%rdx
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<config_read>:
push   %r14
push   %rbx
sub    $0x818,%rsp
lea    0x410(%rsp),%rbx
mov    $0x400,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
lea    0x10(%rsp),%r14
mov    $0x400,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
movl   $0x0,0xc(%rsp)
lea    0xe7c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe79(%rip),%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
lea    0xe6d(%rip),%rdi
lea    0xc(%rsp),%rcx
mov    %rbx,%rsi
mov    %r14,%rdx
call   1040 <item_read@plt>
mov    %eax,%ebx
test   %eax,%eax
je     11c9 <config_read+0x89>
lea    0xe5d(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11e4 <config_read+0xa4>
lea    0xe6c(%rip),%rdi
lea    0x410(%rsp),%rsi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebx,%eax
add    $0x818,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [11 x i8] c"input key:\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [13 x i8] c"./config.txt\00"
@.str.3 = [33 x i8] c"func read configure file err:%d\0A\00"
@.str.4 = [27 x i8] c"your read item is:%s = %s\0A\00"
define i32 @config_read() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = alloca i32
store i32 0, i32* %2
%6 = bitcast [1024 x i8]* %3 to i8*
%7 = bitcast [1024 x i8]* %4 to i8*
store i32 0, i32* %5
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%13 = call i32 @item_read(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %11, i8* %12, i32* %5)
store i32 %13, i32* %2
%14 = load i32, i32* %2
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %0
%17 = load i32, i32* %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %2
store i32 %19, i32* %1
br label %25
20: ; preds = %0
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* %21, i8* %22)
%24 = load i32, i32* %2
store i32 %24, i32* %1
br label %25
25: ; preds = %20, %16
%26 = load i32, i32* %1
ret i32 %26
}

LLVM IR (-O2):
@.str = [11 x i8] c"input key:\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [13 x i8] c"./config.txt\00"
@.str.3 = [33 x i8] c"func read configure file err:%d\0A\00"
@.str.4 = [27 x i8] c"your read item is:%s = %s\0A\00"
define i32 @config_read() {
%1 = alloca [1024 x i8]
%2 = alloca [1024 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%6 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%9 = call i32 @item_read(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %4, i8* %5, i32* %3)
%10 = icmp eq i32 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %0
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %9)
br label %15
13: ; preds = %0
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* %4, i8* %5)
br label %15
15: ; preds = %13, %11
ret i32 %9
}