#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 _Padmake_MakePadFile(char *, long long, int /*<<< orphan*/);
char *_Padmake_PropErrMsg();
long long atoi(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  long long PadSize;
  int ReturnCode;
  char *MsgPtr;
  char test1[16] = "/home/junk/mmm";
  ReturnCode = _Padmake_MakePadFile(test1, 1000, 0);
  if (ReturnCode < 0) {
    MsgPtr = _Padmake_PropErrMsg();
    printf("   Padmake ERROR: %s\n", MsgPtr);
  }
  if (argc < 3) {
    printf("   ERROR: COMMAND LINE: MISSING SIZE\n\n");
    printf("   USAGE:\n      PadMake padfilename size\n");
    return 0;
  }
  PadSize = atoi(argv[2]);
  printf("   MakePad:  %s   OF SIZE: %i\n", argv[1], PadSize);
  ReturnCode = _Padmake_MakePadFile(argv[1], PadSize, 0);
  if (ReturnCode < 0) {
    MsgPtr = _Padmake_PropErrMsg();
    printf("   ERROR MAKING PAD: %i\n", ReturnCode);
    printf("Padmake ERROR: %s\n", MsgPtr);
  } else {
    printf("   PAD MADE: %s - %i BYTES\n", argv[1], PadSize);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xea3(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xea0(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    -0x40(%rbp),%rdi
mov    $0x3e8,%esi
xor    %edx,%edx
call   1050 <_Padmake_MakePadFile@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    11a6 <main+0x66>
mov    $0x0,%al
call   1030 <_Padmake_PropErrMsg@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x3,-0x8(%rbp)
jge    11d8 <main+0x98>
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1277 <main+0x137>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <atoi@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x18(%rbp),%rsi
xor    %edx,%edx
call   1050 <_Padmake_MakePadFile@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1256 <main+0x116>
mov    $0x0,%al
call   1030 <_Padmake_PropErrMsg@plt>
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xdc9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1270 <main+0x130>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
movaps 0xe9c(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
mov    $0x3e8,%esi
xor    %edx,%edx
call   1060 <_Padmake_MakePadFile@plt>
test   %eax,%eax
js     119d <main+0x4d>
cmp    $0x2,%ebp
jg     11ba <main+0x6a>
lea    0xef3(%rip),%rdi
call   1030 <puts@plt>
lea    0xf0d(%rip),%rdi
call   1030 <puts@plt>
jmp    1233 <main+0xe3>
xor    %eax,%eax
call   1040 <_Padmake_PropErrMsg@plt>
lea    0xe65(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x2,%ebp
jle    1180 <main+0x30>
mov    0x10(%rbx),%rdi
call   1070 <atoi@plt>
mov    %rax,%rbp
mov    0x8(%rbx),%rsi
lea    0xe55(%rip),%rdi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rbx),%rdi
mov    %rbp,%rsi
xor    %edx,%edx
call   1060 <_Padmake_MakePadFile@plt>
test   %eax,%eax
js     1204 <main+0xb4>
mov    0x8(%rbx),%rsi
lea    0xe66(%rip),%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1233 <main+0xe3>
mov    %eax,%r14d
xor    %eax,%eax
call   1040 <_Padmake_PropErrMsg@plt>
mov    %rax,%rbx
lea    0xe2d(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xdea(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.test1 = [16 x i8] c"/home/junk/mmm\00\00"
@.str = [22 x i8] c" Padmake ERROR: %s\0A\00"
@.str.1 = [39 x i8] c" ERROR: COMMAND LINE: MISSING SIZE\0A\0A\00"
@.str.2 = [42 x i8] c" USAGE:\0A PadMake padfilename size\0A\00"
@.str.3 = [31 x i8] c" MakePad: %s OF SIZE: %i\0A\00"
@.str.4 = [25 x i8] c" ERROR MAKING PAD: %i\0A\00"
@.str.5 = [19 x i8] c"Padmake ERROR: %s\0A\00"
@.str.6 = [28 x i8] c" PAD MADE: %s - %i BYTES\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i32
%8 = alloca i8*
%9 = alloca [16 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = bitcast [16 x i8]* %9 to i8*
%11 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%12 = call i32 @_Padmake_MakePadFile(i8* %11, i64 1000, i32 0)
store i32 %12, i32* %7
%13 = load i32, i32* %7
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %2
%16 = call i8* (...) @_Padmake_PropErrMsg()
store i8* %16, i8** %8
%17 = load i8*, i8** %8
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %17)
br label %19
19: ; preds = %15, %2
%20 = load i32, i32* %4
%21 = icmp slt i32 %20, 3
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %55
25: ; preds = %19
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 2
%28 = load i8*, i8** %27
%29 = call i64 @atoi(i8* %28)
store i64 %29, i64* %6
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = load i64, i64* %6
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %32, i64 %33)
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 1
%37 = load i8*, i8** %36
%38 = load i64, i64* %6
%39 = call i32 @_Padmake_MakePadFile(i8* %37, i64 %38, i32 0)
store i32 %39, i32* %7
%40 = load i32, i32* %7
%41 = icmp slt i32 %40, 0
br i1 %41, label %42, label %48
42: ; preds = %25
%43 = call i8* (...) @_Padmake_PropErrMsg()
store i8* %43, i8** %8
%44 = load i32, i32* %7
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %44)
%46 = load i8*, i8** %8
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* %46)
br label %54
48: ; preds = %25
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 1
%51 = load i8*, i8** %50
%52 = load i64, i64* %6
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i8* %51, i64 %52)
br label %54
54: ; preds = %48, %42
store i32 0, i32* %3
br label %55
55: ; preds = %54, %22
%56 = load i32, i32* %3
ret i32 %56
}

LLVM IR (-O2):
@__const.main.test1 = [16 x i8] c"/home/junk/mmm\00\00"
@.str = [22 x i8] c" Padmake ERROR: %s\0A\00"
@.str.3 = [31 x i8] c" MakePad: %s OF SIZE: %i\0A\00"
@.str.4 = [25 x i8] c" ERROR MAKING PAD: %i\0A\00"
@.str.5 = [19 x i8] c"Padmake ERROR: %s\0A\00"
@.str.6 = [28 x i8] c" PAD MADE: %s - %i BYTES\0A\00"
@str = [38 x i8] c" ERROR: COMMAND LINE: MISSING SIZE\0A\00"
@str.7 = [41 x i8] c" USAGE:\0A PadMake padfilename size\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [16 x i8]
%4 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%5 = call i32 @_Padmake_MakePadFile(i8* %4, i64 1000, i32 0)
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = call i8* (...) @_Padmake_PropErrMsg()
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %10
10: ; preds = %7, %2
%11 = icmp slt i32 %0, 3
br i1 %11, label %12, label %15
12: ; preds = %10
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.7, i64 0, i64 0))
br label %32
15: ; preds = %10
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = call i64 @atoi(i8* %17)
%19 = getelementptr inbounds i8*, i8** %1, i64 1
%20 = load i8*, i8** %19
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %20, i64 %18)
%22 = load i8*, i8** %19
%23 = call i32 @_Padmake_MakePadFile(i8* %22, i64 %18, i32 0)
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %15
%26 = call i8* (...) @_Padmake_PropErrMsg()
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %23)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* %26)
br label %32
29: ; preds = %15
%30 = load i8*, i8** %19
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i8* %30, i64 %18)
br label %32
32: ; preds = %25, %29, %12
ret i32 0
}