#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 */
char *getenv(char *);
scalar_t__ strcmp(char *, char *);
scalar_t__ strtol(char *, int /*<<< orphan*/ *, int);
int SocializeDebugLevel() {
  char *var = getenv("SocializeDebug");
  if (var == NULL)
    return 0;
  if (strcmp(var, "YES") == 0)
    return 1;
  int level = (int)strtol(var, NULL, 10);
  return level;
}


x86 assembly (clang, -O0):
<SocializeDebugLevel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xec1(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    115f <SocializeDebugLevel+0x2f>
movl   $0x0,-0x4(%rbp)
jmp    11a0 <SocializeDebugLevel+0x70>
mov    -0x10(%rbp),%rdi
lea    0xea5(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1185 <SocializeDebugLevel+0x55>
movl   $0x1,-0x4(%rbp)
jmp    11a0 <SocializeDebugLevel+0x70>
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SocializeDebugLevel>:
push   %rbx
lea    0xec8(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     116a <SocializeDebugLevel+0x3a>
mov    %rax,%rbx
lea    0xec3(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     116e <SocializeDebugLevel+0x3e>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"SocializeDebug\00"
@.str.1 = [4 x i8] c"YES\00"
define i32 @SocializeDebugLevel() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
%4 = call i8* @getenv(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i8* %4, i8** %2
%5 = load i8*, i8** %2
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %8
7: ; preds = %0
store i32 0, i32* %1
br label %18
8: ; preds = %0
%9 = load i8*, i8** %2
%10 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %8
store i32 1, i32* %1
br label %18
13: ; preds = %8
%14 = load i8*, i8** %2
%15 = call i64 @strtol(i8* %14, i32* null, i32 10)
%16 = trunc i64 %15 to i32
store i32 %16, i32* %3
%17 = load i32, i32* %3
store i32 %17, i32* %1
br label %18
18: ; preds = %13, %12, %7
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
@.str = [15 x i8] c"SocializeDebug\00"
@.str.1 = [4 x i8] c"YES\00"
define i32 @SocializeDebugLevel() {
%1 = tail call i8* @getenv(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i8* %1, null
br i1 %2, label %9, label %3
3: ; preds = %0
%4 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %3
%7 = tail call i64 @strtol(i8* nocapture %1, i32* null, i32 10)
%8 = trunc i64 %7 to i32
br label %9
9: ; preds = %3, %0, %6
%10 = phi i32 [ %8, %6 ], [ 0, %0 ], [ 1, %3 ]
ret i32 %10
}