#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 snprintf(char *, int, char *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int strlen(char *);
int show_enable_value(char *val, char *buf, int bsize) {
  if (!val) {
    return -5;
  }
  if (snprintf(buf, bsize, "%s", !strcmp(val, "1") ? "enabled" : "disabled") >=
      bsize) {
    return -2;
  }
  return strlen(buf);
}


x86 assembly (clang, -O0):
<show_enable_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    115a <show_enable_value+0x2a>
movl   $0xfffffffb,-0x4(%rbp)
jmp    11ca <show_enable_value+0x9a>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe90(%rip),%rsi
call   1050 <strcmp@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%esi
cmp    $0x0,%eax
setne  %dl
xor    $0xff,%dl
lea    0xe7e(%rip),%rcx
lea    0xe6f(%rip),%rax
test   $0x1,%dl
cmovne %rax,%rcx
lea    0xe5c(%rip),%rdx
call   1040 <snprintf@plt>
cmp    -0x1c(%rbp),%eax
jl     11be <show_enable_value+0x8e>
movl   $0xfffffffe,-0x4(%rbp)
jmp    11ca <show_enable_value+0x9a>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_enable_value>:
push   %rbp
push   %rbx
push   %rax
test   %rdi,%rdi
je     1187 <show_enable_value+0x57>
mov    %edx,%ebp
mov    %rsi,%rbx
lea    0xebf(%rip),%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
lea    0xeb3(%rip),%rax
lea    0xeb4(%rip),%rcx
cmove  %rax,%rcx
lea    0xe9c(%rip),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <snprintf@plt>
mov    %eax,%ecx
mov    $0xfffffffe,%eax
cmp    %ebp,%ecx
jge    118c <show_enable_value+0x5c>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <strlen@plt>
mov    $0xfffffffb,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [8 x i8] c"enabled\00"
@.str.3 = [9 x i8] c"disabled\00"
define i32 @show_enable_value(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%8 = load i8*, i8** %5
%9 = icmp ne i8* %8, null
br i1 %9, label %11, label %10
10: ; preds = %3
store i32 -5, i32* %4
br label %27
11: ; preds = %3
%12 = load i8*, i8** %6
%13 = load i32, i32* %7
%14 = load i8*, i8** %5
%15 = call i32 @strcmp(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp ne i32 %15, 0
%17 = xor i1 %16, true
%18 = zext i1 %17 to i64
%19 = select i1 %17, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0)
%20 = call i32 @snprintf(i8* %12, i32 %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = load i32, i32* %7
%22 = icmp sge i32 %20, %21
br i1 %22, label %23, label %24
23: ; preds = %11
store i32 -2, i32* %4
br label %27
24: ; preds = %11
%25 = load i8*, i8** %6
%26 = call i32 @strlen(i8* %25)
store i32 %26, i32* %4
br label %27
27: ; preds = %24, %23, %10
%28 = load i32, i32* %4
ret i32 %28
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [8 x i8] c"enabled\00"
@.str.3 = [9 x i8] c"disabled\00"
define i32 @show_enable_value(i8* %0, i8* %1, i32 %2) {
%4 = icmp eq i8* %0, null
br i1 %4, label %13, label %5
5: ; preds = %3
%6 = tail call i32 @strcmp(i8* %0, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i32 %6, 0
%8 = select i1 %7, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0)
%9 = tail call i32 @snprintf(i8* %1, i32 %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = icmp slt i32 %9, %2
br i1 %10, label %11, label %13
11: ; preds = %5
%12 = tail call i32 @strlen(i8* %1)
br label %13
13: ; preds = %5, %3, %11
%14 = phi i32 [ %12, %11 ], [ -5, %3 ], [ -2, %5 ]
ret i32 %14
}