#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int atoi(char *);
int conf_clock(int, int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  int xin, want_gclk2, found, ppm = 100;
  if (argc < 3) {
    fprintf(stderr, "usage: mpc86x_clk <xin> <want_gclk2> [ppm]\n");
    fprintf(stderr, "       default ppm is 100\n");
    return 10;
  }
  xin = atoi(argv[1]);
  want_gclk2 = atoi(argv[2]);
  if (argc >= 4)
    ppm = atoi(argv[3]);
  found = conf_clock(xin, want_gclk2, ppm);
  if (found <= 0) {
    fprintf(stderr, "cannot produce gclk2 %d from xin %d\n", want_gclk2, xin);
    return EXIT_FAILURE;
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x64,-0x20(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1191 <main+0x61>
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
lea    0xe99(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
lea    0xeae(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0xa,-0x4(%rbp)
jmp    1220 <main+0xf0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x4,-0x8(%rbp)
jl     11cb <main+0x9b>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1050 <conf_clock@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jg     1214 <main+0xe4>
mov    0x2df3(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xe4b(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2dce(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1220 <main+0xf0>
mov    0x2db5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jg     116a <main+0x3a>
mov    0x2e9d(%rip),%rbx
mov    (%rbx),%edi
lea    0xeb4(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0xed0(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0xa,%eax
jmp    11da <main+0xaa>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
call   1040 <atoi@plt>
mov    %eax,%r14d
mov    0x10(%rbx),%rdi
call   1040 <atoi@plt>
mov    %eax,%r15d
mov    $0x64,%edx
cmp    $0x3,%ebp
je     119c <main+0x6c>
mov    0x18(%rbx),%rdi
call   1040 <atoi@plt>
mov    %eax,%edx
mov    %r14d,%edi
mov    %r15d,%esi
call   1050 <conf_clock@plt>
test   %eax,%eax
jle    11b4 <main+0x84>
mov    0x2e1e(%rip),%rax
jmp    11d8 <main+0xa8>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
lea    0xe83(%rip),%rsi
mov    %r15d,%edx
mov    %r14d,%ecx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x2e00(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [44 x i8] c"usage: mpc86x_clk <xin> <want_gclk2> [ppm]\0A\00"
@.str.1 = [27 x i8] c" default ppm is 100\0A\00"
@.str.2 = [37 x i8] c"cannot produce gclk2 %d from xin %d\0A\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 100, i32* %9
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 3
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* @stderr
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
store i32 10, i32* %3
br label %48
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @atoi(i8* %20)
store i32 %21, i32* %6
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
%25 = call i32 @atoi(i8* %24)
store i32 %25, i32* %7
%26 = load i32, i32* %4
%27 = icmp sge i32 %26, 4
br i1 %27, label %28, label %33
28: ; preds = %17
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 3
%31 = load i8*, i8** %30
%32 = call i32 @atoi(i8* %31)
store i32 %32, i32* %9
br label %33
33: ; preds = %28, %17
%34 = load i32, i32* %6
%35 = load i32, i32* %7
%36 = load i32, i32* %9
%37 = call i32 @conf_clock(i32 %34, i32 %35, i32 %36)
store i32 %37, i32* %8
%38 = load i32, i32* %8
%39 = icmp sle i32 %38, 0
br i1 %39, label %40, label %46
40: ; preds = %33
%41 = load i32, i32* @stderr
%42 = load i32, i32* %7
%43 = load i32, i32* %6
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %42, i32 %43)
%45 = load i32, i32* @EXIT_FAILURE
store i32 %45, i32* %3
br label %48
46: ; preds = %33
%47 = load i32, i32* @EXIT_SUCCESS
store i32 %47, i32* %3
br label %48
48: ; preds = %46, %40, %12
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [44 x i8] c"usage: mpc86x_clk <xin> <want_gclk2> [ppm]\0A\00"
@.str.1 = [27 x i8] c" default ppm is 100\0A\00"
@.str.2 = [37 x i8] c"cannot produce gclk2 %d from xin %d\0A\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @stderr
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %31
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = tail call i32 @atoi(i8* %14)
%16 = icmp eq i32 %0, 3
br i1 %16, label %21, label %17
17: ; preds = %9
%18 = getelementptr inbounds i8*, i8** %1, i64 3
%19 = load i8*, i8** %18
%20 = tail call i32 @atoi(i8* %19)
br label %21
21: ; preds = %17, %9
%22 = phi i32 [ %20, %17 ], [ 100, %9 ]
%23 = tail call i32 @conf_clock(i32 %12, i32 %15, i32 %22)
%24 = icmp slt i32 %23, 1
br i1 %24, label %25, label %29
25: ; preds = %21
%26 = load i32, i32* @stderr
%27 = tail call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %15, i32 %12)
%28 = load i32, i32* @EXIT_FAILURE
br label %31
29: ; preds = %21
%30 = load i32, i32* @EXIT_SUCCESS
br label %31
31: ; preds = %29, %25, %4
%32 = phi i32 [ 10, %4 ], [ %28, %25 ], [ %30, %29 ]
ret i32 %32
}