#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 /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *,
                           char const *);
char *qt_internal_get_env_str(char const *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, unsigned long);
int /*<<< orphan*/ stderr;
unsigned long strtoul(char const *, char **, int /*<<< orphan*/);
unsigned long __attribute__((visibility("hidden")))
qt_internal_get_env_num(const char *envariable, unsigned long dflt,
                        unsigned long zerodflt) {
  const char *str;
  unsigned long tmp = dflt;
  if (dflt != 0) {
    char dflt_str[10];
    snprintf(dflt_str, 10, "%lu", dflt);
    str = qt_internal_get_env_str(envariable, dflt_str);
  } else {
    str = qt_internal_get_env_str(envariable, NULL);
  }
  if (str && *str) {
    char *errptr;
    tmp = strtoul(str, &errptr, 0);
    if (*errptr != 0) {
      fprintf(stderr, "unparsable %s (%s)\n", envariable, str);
      tmp = dflt;
    }
    if (tmp == 0) {
      do {
      } while (0);
      tmp = zerodflt;
    } else {
      do {
      } while (0);
    }
  }
  return tmp;
}


x86 assembly (clang, -O0):
<qt_internal_get_env_num>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1196 <qt_internal_get_env_num+0x56>
lea    -0x32(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0xa,%esi
lea    0xe85(%rip),%rdx
call   1030 <snprintf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x32(%rbp),%rsi
call   1050 <qt_internal_get_env_str@plt>
mov    %rax,-0x20(%rbp)
jmp    11a7 <qt_internal_get_env_num+0x67>
mov    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <qt_internal_get_env_str@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1240 <qt_internal_get_env_num+0x100>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1240 <qt_internal_get_env_num+0x100>
mov    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rsi
xor    %edx,%edx
call   1060 <strtoul@plt>
mov    %rax,-0x28(%rbp)
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     120a <qt_internal_get_env_num+0xca>
mov    0x2df4(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xe07(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    122c <qt_internal_get_env_num+0xec>
jmp    121a <qt_internal_get_env_num+0xda>
jmp    121f <qt_internal_get_env_num+0xdf>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    123b <qt_internal_get_env_num+0xfb>
jmp    1231 <qt_internal_get_env_num+0xf1>
jmp    1236 <qt_internal_get_env_num+0xf6>
jmp    123b <qt_internal_get_env_num+0xfb>
jmp    1240 <qt_internal_get_env_num+0x100>
mov    -0x28(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<qt_internal_get_env_num>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%r15
test   %rsi,%rsi
je     117d <qt_internal_get_env_num+0x3d>
lea    0xea0(%rip),%rdx
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xa,%esi
mov    %r12,%rcx
call   1030 <snprintf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
jmp    1182 <qt_internal_get_env_num+0x42>
mov    %r15,%rdi
xor    %esi,%esi
call   1050 <qt_internal_get_env_str@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11d4 <qt_internal_get_env_num+0x94>
cmpb   $0x0,(%rbx)
je     11d4 <qt_internal_get_env_num+0x94>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
xor    %edx,%edx
call   1060 <strtoul@plt>
mov    0x8(%rsp),%rcx
cmpb   $0x0,(%rcx)
je     11ca <qt_internal_get_env_num+0x8a>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
lea    0xe47(%rip),%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
call   1040 <fprintf@plt>
jmp    11cd <qt_internal_get_env_num+0x8d>
mov    %rax,%r12
test   %r12,%r12
cmove  %r14,%r12
mov    %r12,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%lu\00"
@stderr = global i32 0
@.str.1 = [20 x i8] c"unparsable %s (%s)\0A\00"
define hidden i64 @qt_internal_get_env_num(i8* %0, i64 %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i64
%9 = alloca [10 x i8]
%10 = alloca i8*
store i8* %0, i8** %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%11 = load i64, i64* %5
store i64 %11, i64* %8
%12 = load i64, i64* %5
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %21
14: ; preds = %3
%15 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 0
%16 = load i64, i64* %5
%17 = call i32 @snprintf(i8* %15, i32 10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %16)
%18 = load i8*, i8** %4
%19 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 0
%20 = call i8* @qt_internal_get_env_str(i8* %18, i8* %19)
store i8* %20, i8** %7
br label %24
21: ; preds = %3
%22 = load i8*, i8** %4
%23 = call i8* @qt_internal_get_env_str(i8* %22, i8* null)
store i8* %23, i8** %7
br label %24
24: ; preds = %21, %14
%25 = load i8*, i8** %7
%26 = icmp ne i8* %25, null
br i1 %26, label %27, label %56
27: ; preds = %24
%28 = load i8*, i8** %7
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %56
32: ; preds = %27
%33 = load i8*, i8** %7
%34 = call i64 @strtoul(i8* %33, i8** %10, i32 0)
store i64 %34, i64* %8
%35 = load i8*, i8** %10
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %45
39: ; preds = %32
%40 = load i32, i32* @stderr
%41 = load i8*, i8** %4
%42 = load i8*, i8** %7
%43 = call i32 @fprintf(i32 %40, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %41, i8* %42)
%44 = load i64, i64* %5
store i64 %44, i64* %8
br label %45
45: ; preds = %39, %32
%46 = load i64, i64* %8
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %52
48: ; preds = %45
br label %49
49: ; preds = %48
br label %50
50: ; preds = %49
%51 = load i64, i64* %6
store i64 %51, i64* %8
br label %55
52: ; preds = %45
br label %53
53: ; preds = %52
br label %54
54: ; preds = %53
br label %55
55: ; preds = %54, %50
br label %56
56: ; preds = %55, %27, %24
%57 = load i64, i64* %8
ret i64 %57
}

LLVM IR (-O2):
@.str = [4 x i8] c"%lu\00"
@stderr = global i32 0
@.str.1 = [20 x i8] c"unparsable %s (%s)\0A\00"
define hidden i64 @qt_internal_get_env_num(i8* %0, i64 %1, i64 %2) {
%4 = alloca [10 x i8]
%5 = alloca i8*
%6 = icmp eq i64 %1, 0
br i1 %6, label %11, label %7
7: ; preds = %3
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%9 = call i32 @snprintf(i8* %8, i32 10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %1)
%10 = call i8* @qt_internal_get_env_str(i8* %0, i8* %8)
br label %13
11: ; preds = %3
%12 = tail call i8* @qt_internal_get_env_str(i8* %0, i8* null)
br label %13
13: ; preds = %11, %7
%14 = phi i8* [ %10, %7 ], [ %12, %11 ]
%15 = icmp eq i8* %14, null
br i1 %15, label %32, label %16
16: ; preds = %13
%17 = load i8, i8* %14
%18 = icmp eq i8 %17, 0
br i1 %18, label %32, label %19
19: ; preds = %16
%20 = bitcast i8** %5 to i8*
%21 = call i64 @strtoul(i8* %14, i8** %5, i32 0)
%22 = load i8*, i8** %5
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
br i1 %24, label %28, label %25
25: ; preds = %19
%26 = load i32, i32* @stderr
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %14)
br label %28
28: ; preds = %25, %19
%29 = phi i64 [ %1, %25 ], [ %21, %19 ]
%30 = icmp eq i64 %29, 0
%31 = select i1 %30, i64 %2, i64 %29
br label %32
32: ; preds = %28, %16, %13
%33 = phi i64 [ %31, %28 ], [ %1, %16 ], [ %1, %13 ]
ret i64 %33
}