#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 */
char *flags(char *);
char *gets(char *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  char name[24];
  char *p, *q;
  int symbol;
  printf("rm ../test.o3/*\n");
  printf("rm ../text.o3/*\n");
  printf("../masmx a1 ../test.o3/a2 -z > ../text.o3/a2.txt\n");
  printf("../masmx a1 ../test.o3/a3 -c > ../text.o3/a3.txt\n");
  printf("../masmx a1 ../test.o3/a4 -zc > ../text.o3/a4.txt\n");
  for (;;) {
    p = gets(name);
    if (!p)
      break;
    while (symbol = *p) {
      if (symbol == '.')
        break;
      p++;
    }
    *p = 0;
    q = flags(name);
    printf("../masmx %s %s ../test.o3/%s > ../text.o3/%s.txt\n", name, q, name,
           name);
  }
  printf("../linkpart\n");
  printf("../coldfire\n");
  printf("../ppc_kern\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf08(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
call   1040 <gets@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11a2 <main+0x72>
jmp    1211 <main+0xe1>
jmp    11a7 <main+0x77>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x34(%rbp)
cmp    $0x0,%eax
je     11da <main+0xaa>
cmpl   $0x2e,-0x34(%rbp)
jne    11c9 <main+0x99>
jmp    11da <main+0xaa>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    11a7 <main+0x77>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x20(%rbp),%rdi
call   1050 <flags@plt>
mov    %rax,-0x30(%rbp)
lea    -0x20(%rbp),%rsi
mov    -0x30(%rbp),%rdx
lea    -0x20(%rbp),%rcx
lea    -0x20(%rbp),%r8
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1185 <main+0x55>
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xee4(%rip),%rdi
call   1030 <puts@plt>
lea    0xee8(%rip),%rdi
call   1030 <puts@plt>
lea    0xeec(%rip),%rdi
call   1030 <puts@plt>
lea    0xf11(%rip),%rdi
call   1030 <puts@plt>
lea    0xf36(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rdi
call   1050 <gets@plt>
test   %rax,%rax
je     11e0 <main+0xa0>
mov    %rsp,%rbx
lea    0xe66(%rip),%r14
jmp    11ce <main+0x8e>
nopl   0x0(%rax)
movb   $0x0,(%rax)
mov    %rbx,%rdi
call   1060 <flags@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
mov    %rbx,%rcx
mov    %rbx,%r8
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1050 <gets@plt>
test   %rax,%rax
je     11e0 <main+0xa0>
movzbl (%rax),%ecx
test   %cl,%cl
je     11a0 <main+0x60>
cmp    $0x2e,%cl
je     11a0 <main+0x60>
add    $0x1,%rax
jmp    11ce <main+0x8e>
lea    0xeff(%rip),%rdi
call   1030 <puts@plt>
lea    0xeff(%rip),%rdi
call   1030 <puts@plt>
lea    0xeff(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [17 x i8] c"rm ../test.o3/*\0A\00"
@.str.1 = [17 x i8] c"rm ../text.o3/*\0A\00"
@.str.2 = [50 x i8] c"../masmx a1 ../test.o3/a2 -z > ../text.o3/a2.txt\0A\00"
@.str.3 = [50 x i8] c"../masmx a1 ../test.o3/a3 -c > ../text.o3/a3.txt\0A\00"
@.str.4 = [51 x i8] c"../masmx a1 ../test.o3/a4 -zc > ../text.o3/a4.txt\0A\00"
@.str.5 = [50 x i8] c"../masmx %s %s ../test.o3/%s > ../text.o3/%s.txt\0A\00"
@.str.6 = [13 x i8] c"../linkpart\0A\00"
@.str.7 = [13 x i8] c"../coldfire\0A\00"
@.str.8 = [13 x i8] c"../ppc_kern\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [24 x i8]
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0))
br label %11
11: ; preds = %30, %0
%12 = getelementptr inbounds [24 x i8], [24 x i8]* %2, i64 0, i64 0
%13 = call i8* @gets(i8* %12)
store i8* %13, i8** %3
%14 = load i8*, i8** %3
%15 = icmp ne i8* %14, null
br i1 %15, label %17, label %16
16: ; preds = %11
br label %39
17: ; preds = %11
br label %18
18: ; preds = %27, %17
%19 = load i8*, i8** %3
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
store i32 %21, i32* %5
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %30
23: ; preds = %18
%24 = load i32, i32* %5
%25 = icmp eq i32 %24, 46
br i1 %25, label %26, label %27
26: ; preds = %23
br label %30
27: ; preds = %23
%28 = load i8*, i8** %3
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %3
br label %18
30: ; preds = %26, %18
%31 = load i8*, i8** %3
store i8 0, i8* %31
%32 = getelementptr inbounds [24 x i8], [24 x i8]* %2, i64 0, i64 0
%33 = call i8* @flags(i8* %32)
store i8* %33, i8** %4
%34 = getelementptr inbounds [24 x i8], [24 x i8]* %2, i64 0, i64 0
%35 = load i8*, i8** %4
%36 = getelementptr inbounds [24 x i8], [24 x i8]* %2, i64 0, i64 0
%37 = getelementptr inbounds [24 x i8], [24 x i8]* %2, i64 0, i64 0
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.5, i64 0, i64 0), i8* %34, i8* %35, i8* %36, i8* %37)
br label %11
39: ; preds = %16
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.5 = [50 x i8] c"../masmx %s %s ../test.o3/%s > ../text.o3/%s.txt\0A\00"
@str = [16 x i8] c"rm ../test.o3/*\00"
@str.9 = [16 x i8] c"rm ../text.o3/*\00"
@str.10 = [49 x i8] c"../masmx a1 ../test.o3/a2 -z > ../text.o3/a2.txt\00"
@str.11 = [49 x i8] c"../masmx a1 ../test.o3/a3 -c > ../text.o3/a3.txt\00"
@str.12 = [50 x i8] c"../masmx a1 ../test.o3/a4 -zc > ../text.o3/a4.txt\00"
@str.13 = [12 x i8] c"../linkpart\00"
@str.14 = [12 x i8] c"../coldfire\00"
@str.15 = [12 x i8] c"../ppc_kern\00"
define i32 @main() {
%1 = alloca [24 x i8]
%2 = getelementptr inbounds [24 x i8], [24 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.9, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.10, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.11, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.12, i64 0, i64 0))
%8 = call i8* @gets(i8* %2)
%9 = icmp eq i8* %8, null
br i1 %9, label %22, label %10
10: ; preds = %0, %15
%11 = phi i8* [ %16, %15 ], [ %8, %0 ]
%12 = load i8, i8* %11
switch i8 %12, label %13 [
i8 46, label %17
i8 0, label %17
]
13: ; preds = %10
%14 = getelementptr inbounds i8, i8* %11, i64 1
br label %15
15: ; preds = %13, %17
%16 = phi i8* [ %14, %13 ], [ %20, %17 ]
br label %10
17: ; preds = %10, %10
store i8 0, i8* %11
%18 = call i8* @flags(i8* %2)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.5, i64 0, i64 0), i8* %2, i8* %18, i8* %2, i8* %2)
%20 = call i8* @gets(i8* %2)
%21 = icmp eq i8* %20, null
br i1 %21, label %22, label %15
22: ; preds = %17, %0
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.13, i64 0, i64 0))
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.14, i64 0, i64 0))
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.15, i64 0, i64 0))
ret i32 0
}