#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 DetectClock(int);
int /*<<< orphan*/ PrintAndLog(char *, int);
int /*<<< orphan*/ sscanf(char const *, char *, int *);
int /*<<< orphan*/ strcmp(char const *, char *);
int GetClock(const char *str, int peak, int verbose) {
  int clock;
  sscanf(str, "%i", &clock);
  if (!strcmp(str, ""))
    clock = 0;
  if (!clock) {
    clock = DetectClock(peak);
    if (!verbose)
      PrintAndLog("Auto-detected clock rate: %d", clock);
  }
  return clock;
}


x86 assembly (clang, -O0):
<GetClock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea3(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1060 <sscanf@plt>
mov    -0x8(%rbp),%rdi
lea    0xeae(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1186 <GetClock+0x46>
movl   $0x0,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    11b9 <GetClock+0x79>
mov    -0xc(%rbp),%edi
call   1030 <DetectClock@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    11b4 <GetClock+0x74>
mov    -0x14(%rbp),%esi
lea    0xe54(%rip),%rdi
call   1040 <PrintAndLog@plt>
jmp    11b9 <GetClock+0x79>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetClock>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xeb9(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1050 <sscanf@plt>
cmpb   $0x0,(%rbx)
je     1160 <GetClock+0x30>
mov    0xc(%rsp),%eax
test   %eax,%eax
jne    118a <GetClock+0x5a>
jmp    1168 <GetClock+0x38>
movl   $0x0,0xc(%rsp)
mov    %ebp,%edi
call   1030 <DetectClock@plt>
mov    %eax,0xc(%rsp)
test   %r14d,%r14d
jne    118a <GetClock+0x5a>
lea    0xe84(%rip),%rdi
mov    %eax,%esi
call   1040 <PrintAndLog@plt>
mov    0xc(%rsp),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%i\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [29 x i8] c"Auto-detected clock rate: %d\00"
define i32 @GetClock(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i8*, i8** %4
%9 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
%10 = load i8*, i8** %4
%11 = call i32 @strcmp(i8* %10, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp ne i32 %11, 0
br i1 %12, label %14, label %13
13: ; preds = %3
store i32 0, i32* %7
br label %14
14: ; preds = %13, %3
%15 = load i32, i32* %7
%16 = icmp ne i32 %15, 0
br i1 %16, label %26, label %17
17: ; preds = %14
%18 = load i32, i32* %5
%19 = call i32 @DetectClock(i32 %18)
store i32 %19, i32* %7
%20 = load i32, i32* %6
%21 = icmp ne i32 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %17
%23 = load i32, i32* %7
%24 = call i32 @PrintAndLog(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %22, %17
br label %26
26: ; preds = %25, %14
%27 = load i32, i32* %7
ret i32 %27
}

LLVM IR (-O2):
@.str = [3 x i8] c"%i\00"
@.str.2 = [29 x i8] c"Auto-detected clock rate: %d\00"
define i32 @GetClock(i8* nocapture %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
%6 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%7 = load i8, i8* %0
%8 = icmp eq i8 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %3
store i32 0, i32* %4
br label %13
10: ; preds = %3
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %9, %10
%14 = call i32 @DetectClock(i32 %1)
store i32 %14, i32* %4
%15 = icmp eq i32 %2, 0
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = call i32 @PrintAndLog(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %14)
%18 = load i32, i32* %4
br label %19
19: ; preds = %13, %16, %10
%20 = phi i32 [ %14, %13 ], [ %18, %16 ], [ %11, %10 ]
ret i32 %20
}