#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 */
typedef int /*<<< orphan*/ programName;
typedef int /*<<< orphan*/ arg1Buffer;

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ getRational(int, char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int main(int argc, char *argv[]) {
  char programName[16];
  snprintf(programName, sizeof(programName), "%s", argv[0]);
  if (argc == 1) {
    printf("[%s Syntax] : %s NUM\n", programName, programName);
    printf("   where NUM is a positive int\n");
    return 0;
  }
  char arg1Buffer[21];
  snprintf(arg1Buffer, sizeof(arg1Buffer), "%s", argv[1]);
  int n = atoi(arg1Buffer);
  char strFn[100];
  int mode = 0;
  if (argc > 2) {
    mode = 1;
  }
  getRational(n, strFn, mode);
  printf("\n\n***    f(%d) = %s    ***\n", n, strFn);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
mov    $0x10,%esi
lea    0xe90(%rip),%rdx
call   1040 <snprintf@plt>
cmpl   $0x1,-0x8(%rbp)
jne    11af <main+0x6f>
lea    -0x20(%rbp),%rsi
lea    -0x20(%rbp),%rdx
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    122a <main+0xea>
lea    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
mov    $0x15,%esi
lea    0xe39(%rip),%rdx
call   1040 <snprintf@plt>
lea    -0x40(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x44(%rbp)
movl   $0x0,-0xb4(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    11f6 <main+0xb6>
movl   $0x1,-0xb4(%rbp)
mov    -0x44(%rbp),%edi
lea    -0xb0(%rbp),%rsi
mov    -0xb4(%rbp),%edx
call   1050 <getRational@plt>
mov    -0x44(%rbp),%esi
lea    -0xb0(%rbp),%rdx
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x98,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
mov    (%rsi),%rcx
lea    0xe98(%rip),%rdx
mov    %rsp,%rdi
mov    $0x10,%esi
call   1050 <snprintf@plt>
cmp    $0x1,%ebp
jne    119c <main+0x4c>
lea    0xe82(%rip),%rdi
mov    %rsp,%rdx
mov    %rdx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea0(%rip),%rdi
call   1030 <puts@plt>
jmp    11ed <main+0x9d>
mov    0x8(%rbx),%rcx
lea    0xe59(%rip),%rdx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x15,%esi
call   1050 <snprintf@plt>
mov    %rbx,%rdi
call   1070 <atoi@plt>
mov    %eax,%ebx
xor    %edx,%edx
cmp    $0x3,%ebp
setge  %dl
lea    0x30(%rsp),%rbp
mov    %eax,%edi
mov    %rbp,%rsi
call   1060 <getRational@plt>
lea    0xe38(%rip),%rdi
mov    %ebx,%esi
mov    %rbp,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x98,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [22 x i8] c"[%s Syntax] : %s NUM\0A\00"
@.str.2 = [32 x i8] c" where NUM is a positive int\0A\00"
@.str.3 = [28 x i8] c"\0A\0A*** f(%d) = %s ***\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [16 x i8]
%7 = alloca [21 x i8]
%8 = alloca i32
%9 = alloca [100 x i8]
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @snprintf(i8* %11, i32 16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %23
18: ; preds = %2
%19 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%20 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %19, i8* %20)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %42
23: ; preds = %2
%24 = getelementptr inbounds [21 x i8], [21 x i8]* %7, i64 0, i64 0
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i32 @snprintf(i8* %24, i32 21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %27)
%29 = getelementptr inbounds [21 x i8], [21 x i8]* %7, i64 0, i64 0
%30 = call i32 @atoi(i8* %29)
store i32 %30, i32* %8
store i32 0, i32* %10
%31 = load i32, i32* %4
%32 = icmp sgt i32 %31, 2
br i1 %32, label %33, label %34
33: ; preds = %23
store i32 1, i32* %10
br label %34
34: ; preds = %33, %23
%35 = load i32, i32* %8
%36 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%37 = load i32, i32* %10
%38 = call i32 @getRational(i32 %35, i8* %36, i32 %37)
%39 = load i32, i32* %8
%40 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %39, i8* %40)
store i32 0, i32* %3
br label %42
42: ; preds = %34, %18
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [22 x i8] c"[%s Syntax] : %s NUM\0A\00"
@.str.3 = [28 x i8] c"\0A\0A*** f(%d) = %s ***\0A\00"
@str = [31 x i8] c" where NUM is a positive int\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [16 x i8]
%4 = alloca [21 x i8]
%5 = alloca [100 x i8]
%6 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%7 = load i8*, i8** %1
%8 = call i32 @snprintf(i8* %6, i32 16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = icmp eq i32 %0, 1
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %6, i8* %6)
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
br label %24
13: ; preds = %2
%14 = getelementptr inbounds [21 x i8], [21 x i8]* %4, i64 0, i64 0
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @snprintf(i8* %14, i32 21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = call i32 @atoi(i8* %14)
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%20 = icmp sgt i32 %0, 2
%21 = zext i1 %20 to i32
%22 = call i32 @getRational(i32 %18, i8* %19, i32 %21)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %18, i8* %19)
br label %24
24: ; preds = %13, %10
ret i32 0
}