#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*/ free(char *);
int /*<<< orphan*/ inputError();
char *piChudnovsky(unsigned long);
int /*<<< orphan*/ printf(char *, ...);
unsigned long strtol(char const *, char **, int);
int main(int argc, const char *argv[]) {
  unsigned long numberOfDigits = 100;
  if (argc == 2) {
    if (argv[1][0] == '-')
      inputError();
    char *endptr;
    numberOfDigits = strtol(argv[1], &endptr, 10);
    if (*endptr != '\0')
      inputError();
  } else
    inputError();
  if (numberOfDigits < 1)
    inputError();
  else if (numberOfDigits == 1) {
    printf("3\n");
    return 0;
  }
  char *piString = piChudnovsky(numberOfDigits);
  printf("%.1s.%s\n", piString, piString + 1);
  free(piString);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x64,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    11c9 <main+0x79>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1193 <main+0x43>
mov    $0x0,%al
call   1070 <inputError@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x20(%rbp),%rsi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11c4 <main+0x74>
mov    $0x0,%al
call   1070 <inputError@plt>
jmp    11d0 <main+0x80>
mov    $0x0,%al
call   1070 <inputError@plt>
cmpq   $0x1,-0x18(%rbp)
jae    11e7 <main+0x97>
mov    $0x0,%al
call   1070 <inputError@plt>
jmp    1211 <main+0xc1>
cmpq   $0x1,-0x18(%rbp)
jne    120c <main+0xbc>
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1248 <main+0xf8>
jmp    1211 <main+0xc1>
mov    -0x18(%rbp),%rdi
call   1050 <piChudnovsky@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
mov    -0x28(%rbp),%rdx
add    $0x1,%rdx
lea    0xdd2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x64,%ebx
cmp    $0x2,%edi
jne    11be <main+0x5e>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
cmpb   $0x2d,(%rdi)
jne    1185 <main+0x25>
xor    %eax,%eax
call   1080 <inputError@plt>
mov    0x8(%r14),%rdi
mov    %rsp,%rsi
mov    $0xa,%edx
call   1070 <strtol@plt>
mov    %rax,%rbx
mov    (%rsp),%rax
cmpb   $0x0,(%rax)
je     11a5 <main+0x45>
xor    %eax,%eax
call   1080 <inputError@plt>
test   %rbx,%rbx
je     11be <main+0x5e>
cmp    $0x1,%rbx
jne    11c5 <main+0x65>
lea    0xe52(%rip),%rdi
call   1040 <puts@plt>
jmp    11ed <main+0x8d>
xor    %eax,%eax
call   1080 <inputError@plt>
mov    %rbx,%rdi
call   1060 <piChudnovsky@plt>
mov    %rax,%rbx
lea    0x1(%rax),%rdx
lea    0xe25(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str.1 = [9 x i8] c"%.1s.%s\0A\00"
@str = [2 x i8] c"3\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = icmp eq i32 %0, 2
br i1 %4, label %5, label %25
5: ; preds = %2
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 45
br i1 %9, label %10, label %13
10: ; preds = %5
%11 = tail call i32 (...) @inputError()
%12 = load i8*, i8** %6
br label %13
13: ; preds = %10, %5
%14 = phi i8* [ %12, %10 ], [ %7, %5 ]
%15 = bitcast i8** %3 to i8*
%16 = call i64 @strtol(i8* %14, i8** %3, i32 10)
%17 = load i8*, i8** %3
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %13
%21 = tail call i32 (...) @inputError()
br label %22
22: ; preds = %13, %20
switch i64 %16, label %28 [
i64 0, label %25
i64 1, label %23
]
23: ; preds = %22
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
br label %34
25: ; preds = %22, %2
%26 = phi i64 [ 100, %2 ], [ %16, %22 ]
%27 = tail call i32 (...) @inputError()
br label %28
28: ; preds = %25, %22
%29 = phi i64 [ %16, %22 ], [ %26, %25 ]
%30 = tail call i8* @piChudnovsky(i64 %29)
%31 = getelementptr inbounds i8, i8* %30, i64 1
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %30, i8* %31)
%33 = tail call i32 @free(i8* %30)
br label %34
34: ; preds = %28, %23
ret i32 0
}