#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 */
struct ipr_ioa {
  int dummy;
};

/* Variables and functions */
scalar_t__ ipr_read_host_attr(struct ipr_ioa *, char *, char *, int);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int get_log_level(struct ipr_ioa *ioa) {
  char value_str[100];
  int value;
  if (ipr_read_host_attr(ioa, "log_level", value_str, 100) < 0)
    return 0;
  sscanf(value_str, "%d", &value);
  return value;
}


x86 assembly (clang, -O0):
<get_log_level>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x80(%rbp),%rdx
lea    0xec2(%rip),%rsi
mov    $0x64,%ecx
call   1040 <ipr_read_host_attr@plt>
cmp    $0x0,%rax
jge    115e <get_log_level+0x3e>
movl   $0x0,-0x4(%rbp)
jmp    117e <get_log_level+0x5e>
lea    -0x80(%rbp),%rdi
lea    0xea1(%rip),%rsi
lea    -0x84(%rbp),%rdx
call   1030 <sscanf@plt>
mov    -0x84(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_log_level>:
sub    $0x78,%rsp
lea    0xed5(%rip),%rsi
lea    0x10(%rsp),%rdx
mov    $0x64,%ecx
call   1040 <ipr_read_host_attr@plt>
test   %rax,%rax
js     115e <get_log_level+0x3e>
lea    0xec4(%rip),%rsi
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rdx
call   1030 <sscanf@plt>
mov    0xc(%rsp),%eax
add    $0x78,%rsp
ret
xor    %eax,%eax
add    $0x78,%rsp
ret

LLVM IR (-O0):
%struct.ipr_ioa = type { i32 }
@.str = [10 x i8] c"log_level\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @get_log_level(%struct.ipr_ioa* %0) {
%2 = alloca i32
%3 = alloca %struct.ipr_ioa*
%4 = alloca [100 x i8]
%5 = alloca i32
store %struct.ipr_ioa* %0, %struct.ipr_ioa** %3
%6 = load %struct.ipr_ioa*, %struct.ipr_ioa** %3
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%8 = call i64 @ipr_read_host_attr(%struct.ipr_ioa* %6, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %7, i32 100)
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 0, i32* %2
br label %15
11: ; preds = %1
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%13 = call i32 @sscanf(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%14 = load i32, i32* %5
store i32 %14, i32* %2
br label %15
15: ; preds = %11, %10
%16 = load i32, i32* %2
ret i32 %16
}

LLVM IR (-O2):
%struct.ipr_ioa = type { i32 }
@.str = [10 x i8] c"log_level\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @get_log_level(%struct.ipr_ioa* %0) {
%2 = alloca [100 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = bitcast i32* %3 to i8*
%6 = call i64 @ipr_read_host_attr(%struct.ipr_ioa* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %4, i32 100)
%7 = icmp slt i64 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %1
%9 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%10 = load i32, i32* %3
br label %11
11: ; preds = %1, %8
%12 = phi i32 [ %10, %8 ], [ 0, %1 ]
ret i32 %12
}