#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ ensureValid(char *, int *, int *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int rand();
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ strcasecmp(char *, char *);
int strlen(char *);
int /*<<< orphan*/ system(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  char beforefile[1024], aftercomb[1024], outputfile[1024], convcmd[1024],
      nocvcmd[1024], cleancmd[1024];
  char *end;
  char buff[1024], syscmd[1024];
  FILE *sysout;
  FILE *filechk;
  FILE *rectfp;
  char images;
  int combchoice;
  int width = 0, height = 0;
  if (argc != 3)
    return 0;
  sprintf(beforefile, "data/%s.jpg", argv[1]);
  sprintf(aftercomb,
          "/home/jrising/tmp/tapest/%s/"
          "bgfull2.jpg",
          argv[1]);
  sprintf(outputfile,
          "/home/jrising/tmp/tapest/%s/"
          "bgfull3.jpg",
          argv[1]);
  sprintf(convcmd,
          "convert -modulate 99 "
          "/home/jrising/tmp/tapest/%s/"
          "bgfull2.jpg "
          "/home/jrising/tmp/tapest/%s/"
          "bgfull3.jpg",
          argv[1], argv[1]);
  sprintf(nocvcmd,
          "mv "
          "/home/jrising/tmp/tapest/%s/"
          "bgfull2.jpg "
          "/home/jrising/tmp/tapest/%s/"
          "bgfull3.jpg",
          argv[1], argv[1]);
  sprintf(cleancmd,
          "mv "
          "/home/jrising/tmp/tapest/%s/"
          "bgfull3.jpg data/%s.jpg",
          argv[1]);
  end = argv[2] + strlen(argv[2]) - 4;
  srand(time(NULL));
  if (!strcasecmp(end, "jpeg") || !strcasecmp(end, ".jpg") ||
      (!strcasecmp(end, ".gif") || !strcasecmp(end, "tiff") ||
       !strcasecmp(end, ".ppm") || !strcasecmp(end, ".bmp") ||
       !strcasecmp(end, "pict") || !strcasecmp(end, ".pnm") ||
       !strcasecmp(end, ".png")) &&
          !0) {
    while (filechk = fopen(outputfile, "r"))
      fclose(filechk);
    if (!ensureValid(beforefile, &width, &height))
      exit(0);
    combchoice = (rand() % 3) * 1;
    if (combchoice == 0)
      sprintf(syscmd,
              "composite -compose atop -geometry +%d+%d \"%s\" data/%s.jpg "
              "/home/jrising/tmp/tapest/%s/"
              "bgfull2.jpg",
              rand() % width - 50, rand() % height - 50, argv[2], argv[1],
              argv[1]);
    else if (combchoice == 1)
      sprintf(syscmd,
              "composite -compose atop -geometry +%d+%d \"%s\" data/%s.jpg "
              "/home/jrising/tmp/tapest/%s/"
              "bgfull2.jpg",
              rand() % width - 50, rand() % height - 50, argv[2], argv[1],
              argv[1]);
    else
      sprintf(syscmd,
              "composite -compose atop -geometry +%d+%d \"%s\" data/%s.jpg "
              "/home/jrising/tmp/tapest/%s/"
              "bgfull2.jpg",
              rand() % width - 50, rand() % height - 50, argv[2], argv[1],
              argv[1]);
    printf("%s\n", syscmd);
    system(syscmd);
    if (!ensureValid(aftercomb, &width, &height))
      exit(0);
    if (rand() % 2 == 0)
      system(convcmd);
    else
      system(nocvcmd);
    if (!ensureValid(outputfile, &width, &height))
      exit(0);
    system(cleancmd);
    system("xli -onroot -quiet -fork bgfull.gif");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2090,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x2044(%rbp)
movl   $0x0,-0x2048(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1203 <main+0x43>
movl   $0x0,-0x4(%rbp)
jmp    16b5 <main+0x4f5>
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xeca(%rip),%rsi
mov    $0x0,%al
call   10c0 <sprintf@plt>
lea    -0x810(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xf18(%rip),%rsi
mov    $0x0,%al
call   10c0 <sprintf@plt>
lea    -0xc10(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xdea(%rip),%rsi
mov    $0x0,%al
call   10c0 <sprintf@plt>
lea    -0x1010(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xd88(%rip),%rsi
mov    $0x0,%al
call   10c0 <sprintf@plt>
lea    -0x1410(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xdc8(%rip),%rsi
mov    $0x0,%al
call   10c0 <sprintf@plt>
lea    -0x1810(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xdfe(%rip),%rsi
mov    $0x0,%al
call   10c0 <sprintf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x2050(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x2050(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0xfffffffffffffffc,%rax
mov    %rax,-0x1818(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   10a0 <time@plt>
mov    %eax,%edi
call   1090 <srand@plt>
mov    -0x1818(%rbp),%rdi
lea    0xdda(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
je     1403 <main+0x243>
mov    -0x1818(%rbp),%rdi
lea    0xe40(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
je     1403 <main+0x243>
mov    -0x1818(%rbp),%rdi
lea    0xe4c(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
je     1403 <main+0x243>
mov    -0x1818(%rbp),%rdi
lea    0xd8b(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
je     1403 <main+0x243>
mov    -0x1818(%rbp),%rdi
lea    0xd74(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
je     1403 <main+0x243>
mov    -0x1818(%rbp),%rdi
lea    0xd5d(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
je     1403 <main+0x243>
mov    -0x1818(%rbp),%rdi
lea    0xd46(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
je     1403 <main+0x243>
mov    -0x1818(%rbp),%rdi
lea    0xd2f(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
je     1403 <main+0x243>
mov    -0x1818(%rbp),%rdi
lea    0xd18(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    16b5 <main+0x4f5>
jmp    1408 <main+0x248>
lea    -0xc10(%rbp),%rdi
lea    0xcfc(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x2030(%rbp)
cmp    $0x0,%rax
je     143d <main+0x27d>
mov    -0x2030(%rbp),%rdi
call   1040 <fclose@plt>
jmp    1408 <main+0x248>
lea    -0x410(%rbp),%rdi
lea    -0x2044(%rbp),%rsi
lea    -0x2048(%rbp),%rdx
call   1080 <ensureValid@plt>
cmp    $0x0,%eax
jne    1467 <main+0x2a7>
xor    %edi,%edi
call   10d0 <exit@plt>
mov    $0x0,%al
call   10e0 <rand@plt>
mov    $0x3,%ecx
cltd
idiv   %ecx
shl    $0x0,%edx
mov    %edx,-0x2040(%rbp)
cmpl   $0x0,-0x2040(%rbp)
jne    1500 <main+0x340>
lea    -0x2020(%rbp),%rax
mov    %rax,-0x2060(%rbp)
mov    $0x0,%al
call   10e0 <rand@plt>
cltd
idivl  -0x2044(%rbp)
sub    $0x32,%edx
mov    %edx,-0x2054(%rbp)
mov    $0x0,%al
call   10e0 <rand@plt>
mov    -0x2060(%rbp),%rdi
cltd
idivl  -0x2048(%rbp)
mov    %edx,%ecx
mov    -0x2054(%rbp),%edx
sub    $0x32,%ecx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%r8
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%r9
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
lea    0xc24(%rip),%rsi
mov    %rax,(%rsp)
mov    $0x0,%al
call   10c0 <sprintf@plt>
jmp    15f5 <main+0x435>
cmpl   $0x1,-0x2040(%rbp)
jne    1581 <main+0x3c1>
lea    -0x2020(%rbp),%rax
mov    %rax,-0x2070(%rbp)
mov    $0x0,%al
call   10e0 <rand@plt>
cltd
idivl  -0x2044(%rbp)
sub    $0x32,%edx
mov    %edx,-0x2064(%rbp)
mov    $0x0,%al
call   10e0 <rand@plt>
mov    -0x2070(%rbp),%rdi
cltd
idivl  -0x2048(%rbp)
mov    %edx,%ecx
mov    -0x2064(%rbp),%edx
sub    $0x32,%ecx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%r8
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%r9
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
lea    0xba3(%rip),%rsi
mov    %rax,(%rsp)
mov    $0x0,%al
call   10c0 <sprintf@plt>
jmp    15f0 <main+0x430>
lea    -0x2020(%rbp),%rax
mov    %rax,-0x2080(%rbp)
mov    $0x0,%al
call   10e0 <rand@plt>
cltd
idivl  -0x2044(%rbp)
sub    $0x32,%edx
mov    %edx,-0x2074(%rbp)
mov    $0x0,%al
call   10e0 <rand@plt>
mov    -0x2080(%rbp),%rdi
cltd
idivl  -0x2048(%rbp)
mov    %edx,%ecx
mov    -0x2074(%rbp),%edx
sub    $0x32,%ecx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%r8
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%r9
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
lea    0xb2f(%rip),%rsi
mov    %rax,(%rsp)
mov    $0x0,%al
call   10c0 <sprintf@plt>
jmp    15f5 <main+0x435>
lea    -0x2020(%rbp),%rsi
lea    0xb73(%rip),%rdi
call   1070 <printf@plt>
lea    -0x2020(%rbp),%rdi
call   1060 <system@plt>
lea    -0x810(%rbp),%rdi
lea    -0x2044(%rbp),%rsi
lea    -0x2048(%rbp),%rdx
call   1080 <ensureValid@plt>
cmp    $0x0,%eax
jne    163e <main+0x47e>
xor    %edi,%edi
call   10d0 <exit@plt>
mov    $0x0,%al
call   10e0 <rand@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1667 <main+0x4a7>
lea    -0x1010(%rbp),%rdi
call   1060 <system@plt>
jmp    1673 <main+0x4b3>
lea    -0x1410(%rbp),%rdi
call   1060 <system@plt>
lea    -0xc10(%rbp),%rdi
lea    -0x2044(%rbp),%rsi
lea    -0x2048(%rbp),%rdx
call   1080 <ensureValid@plt>
cmp    $0x0,%eax
jne    169d <main+0x4dd>
xor    %edi,%edi
call   10d0 <exit@plt>
lea    -0x1810(%rbp),%rdi
call   1060 <system@plt>
lea    0xaca(%rip),%rdi
call   1060 <system@plt>
mov    -0x4(%rbp),%eax
add    $0x2090,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1c10,%rsp
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
cmp    $0x3,%edi
jne    14c1 <main+0x301>
mov    %rsi,%r13
mov    0x8(%rsi),%rdx
lea    0xeec(%rip),%rsi
lea    0x1010(%rsp),%rdi
xor    %eax,%eax
call   10c0 <sprintf@plt>
mov    0x8(%r13),%rdx
lea    0xf3d(%rip),%rsi
lea    0xc10(%rsp),%rdi
xor    %eax,%eax
call   10c0 <sprintf@plt>
mov    0x8(%r13),%rdx
lea    0xe12(%rip),%rsi
lea    0x410(%rsp),%rdi
xor    %eax,%eax
call   10c0 <sprintf@plt>
mov    0x8(%r13),%rcx
lea    0xdbb(%rip),%rsi
lea    0x1810(%rsp),%r14
mov    %r14,%rdi
mov    %rcx,%rdx
xor    %eax,%eax
call   10c0 <sprintf@plt>
mov    0x8(%r13),%rcx
lea    0xe00(%rip),%rsi
lea    0x1410(%rsp),%r15
mov    %r15,%rdi
mov    %rcx,%rdx
xor    %eax,%eax
call   10c0 <sprintf@plt>
mov    0x8(%r13),%rdx
lea    0xe33(%rip),%rsi
lea    0x810(%rsp),%rdi
xor    %eax,%eax
call   10c0 <sprintf@plt>
mov    0x10(%r13),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
lea    (%rbx,%rax,1),%r12
add    $0xfffffffffffffffc,%r12
xor    %edi,%edi
call   10a0 <time@plt>
mov    %eax,%edi
call   1090 <srand@plt>
lea    0xe30(%rip),%rsi
mov    %r12,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     136f <main+0x1af>
lea    0xe9b(%rip),%rsi
mov    %r12,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     136f <main+0x1af>
lea    0xeac(%rip),%rsi
mov    %r12,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     136f <main+0x1af>
lea    0xdf4(%rip),%rsi
mov    %r12,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     136f <main+0x1af>
lea    0xde6(%rip),%rsi
mov    %r12,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     136f <main+0x1af>
lea    0xdd8(%rip),%rsi
mov    %r12,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     136f <main+0x1af>
lea    0xdca(%rip),%rsi
mov    %r12,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     136f <main+0x1af>
lea    0xdbc(%rip),%rsi
mov    %r12,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     136f <main+0x1af>
lea    0xdae(%rip),%rsi
mov    %r12,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
jne    14c1 <main+0x301>
lea    0xd9c(%rip),%rsi
lea    0x410(%rsp),%rdi
call   10b0 <fopen@plt>
test   %rax,%rax
je     13b8 <main+0x1f8>
lea    0xd83(%rip),%r12
lea    0x410(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
mov    %rax,%rdi
call   1040 <fclose@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
jne    13a0 <main+0x1e0>
lea    0x1010(%rsp),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1080 <ensureValid@plt>
test   %eax,%eax
je     14d4 <main+0x314>
xor    %eax,%eax
call   10e0 <rand@plt>
cltq
imul   $0x55555556,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
cmp    $0x1,%eax
je     1400 <main+0x240>
test   %eax,%eax
xor    %eax,%eax
call   10e0 <rand@plt>
cltd
idivl  0xc(%rsp)
mov    %edx,%ebx
add    $0xffffffce,%ebx
xor    %eax,%eax
call   10e0 <rand@plt>
cltd
idivl  0x8(%rsp)
lea    -0x32(%rdx),%ecx
mov    0x8(%r13),%r9
mov    0x10(%r13),%r8
mov    %r9,(%rsp)
lea    0xce1(%rip),%rsi
lea    0x10(%rsp),%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   10c0 <sprintf@plt>
lea    0xd2e(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
call   1070 <printf@plt>
mov    %rbx,%rdi
call   1060 <system@plt>
lea    0xc10(%rsp),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1080 <ensureValid@plt>
test   %eax,%eax
je     14d4 <main+0x314>
xor    %eax,%eax
call   10e0 <rand@plt>
test   $0x1,%al
cmove  %r14,%r15
mov    %r15,%rdi
call   1060 <system@plt>
lea    0x410(%rsp),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1080 <ensureValid@plt>
test   %eax,%eax
je     14d4 <main+0x314>
lea    0x810(%rsp),%rdi
call   1060 <system@plt>
lea    0xcbe(%rip),%rdi
call   1060 <system@plt>
xor    %eax,%eax
add    $0x1c10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
xor    %edi,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"data/%s.jpg\00"
@.str.1 = [40 x i8] c"/home/jrising/tmp/tapest/%s/bgfull2.jpg\00"
@.str.2 = [40 x i8] c"/home/jrising/tmp/tapest/%s/bgfull3.jpg\00"
@.str.3 = [101 x i8] c"convert -modulate 99 /home/jrising/tmp/tapest/%s/bgfull2.jpg /home/jrising/tmp/tapest/%s/bgfull3.jpg\00"
@.str.4 = [83 x i8] c"mv /home/jrising/tmp/tapest/%s/bgfull2.jpg /home/jrising/tmp/tapest/%s/bgfull3.jpg\00"
@.str.5 = [55 x i8] c"mv /home/jrising/tmp/tapest/%s/bgfull3.jpg data/%s.jpg\00"
@.str.6 = [5 x i8] c"jpeg\00"
@.str.7 = [5 x i8] c".jpg\00"
@.str.8 = [5 x i8] c".gif\00"
@.str.9 = [5 x i8] c"tiff\00"
@.str.10 = [5 x i8] c".ppm\00"
@.str.11 = [5 x i8] c".bmp\00"
@.str.12 = [5 x i8] c"pict\00"
@.str.13 = [5 x i8] c".pnm\00"
@.str.14 = [5 x i8] c".png\00"
@.str.15 = [2 x i8] c"r\00"
@.str.16 = [98 x i8] c"composite -compose atop -geometry +%d+%d \22%s\22 data/%s.jpg /home/jrising/tmp/tapest/%s/bgfull2.jpg\00"
@.str.17 = [4 x i8] c"%s\0A\00"
@.str.18 = [36 x i8] c"xli -onroot -quiet -fork bgfull.gif\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1024 x i8]
%7 = alloca [1024 x i8]
%8 = alloca [1024 x i8]
%9 = alloca [1024 x i8]
%10 = alloca [1024 x i8]
%11 = alloca [1024 x i8]
%12 = alloca i8*
%13 = alloca [1024 x i8]
%14 = alloca [1024 x i8]
%15 = alloca i32*
%16 = alloca i32*
%17 = alloca i32*
%18 = alloca i8
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %20
store i32 0, i32* %21
%22 = load i32, i32* %4
%23 = icmp ne i32 %22, 3
br i1 %23, label %24, label %25
24: ; preds = %2
store i32 0, i32* %3
br label %223
25: ; preds = %2
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32 (i8*, i8*, ...) @sprintf(i8* %26, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %29)
%31 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i32 (i8*, i8*, ...) @sprintf(i8* %31, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i8* %34)
%36 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 1
%39 = load i8*, i8** %38
%40 = call i32 (i8*, i8*, ...) @sprintf(i8* %36, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i8* %39)
%41 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 1
%44 = load i8*, i8** %43
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 1
%47 = load i8*, i8** %46
%48 = call i32 (i8*, i8*, ...) @sprintf(i8* %41, i8* getelementptr inbounds ([101 x i8], [101 x i8]* @.str.3, i64 0, i64 0), i8* %44, i8* %47)
%49 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 1
%52 = load i8*, i8** %51
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 1
%55 = load i8*, i8** %54
%56 = call i32 (i8*, i8*, ...) @sprintf(i8* %49, i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.4, i64 0, i64 0), i8* %52, i8* %55)
%57 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%58 = load i8**, i8*** %5
%59 = getelementptr inbounds i8*, i8** %58, i64 1
%60 = load i8*, i8** %59
%61 = call i32 (i8*, i8*, ...) @sprintf(i8* %57, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.5, i64 0, i64 0), i8* %60)
%62 = load i8**, i8*** %5
%63 = getelementptr inbounds i8*, i8** %62, i64 2
%64 = load i8*, i8** %63
%65 = load i8**, i8*** %5
%66 = getelementptr inbounds i8*, i8** %65, i64 2
%67 = load i8*, i8** %66
%68 = call i32 @strlen(i8* %67)
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i8, i8* %64, i64 %69
%71 = getelementptr inbounds i8, i8* %70, i64 -4
store i8* %71, i8** %12
%72 = call i32 @time(i32* null)
%73 = call i32 @srand(i32 %72)
%74 = load i8*, i8** %12
%75 = call i32 @strcasecmp(i8* %74, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%76 = icmp ne i32 %75, 0
br i1 %76, label %77, label %109
77: ; preds = %25
%78 = load i8*, i8** %12
%79 = call i32 @strcasecmp(i8* %78, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%80 = icmp ne i32 %79, 0
br i1 %80, label %81, label %109
81: ; preds = %77
%82 = load i8*, i8** %12
%83 = call i32 @strcasecmp(i8* %82, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%84 = icmp ne i32 %83, 0
br i1 %84, label %85, label %109
85: ; preds = %81
%86 = load i8*, i8** %12
%87 = call i32 @strcasecmp(i8* %86, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%88 = icmp ne i32 %87, 0
br i1 %88, label %89, label %109
89: ; preds = %85
%90 = load i8*, i8** %12
%91 = call i32 @strcasecmp(i8* %90, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%92 = icmp ne i32 %91, 0
br i1 %92, label %93, label %109
93: ; preds = %89
%94 = load i8*, i8** %12
%95 = call i32 @strcasecmp(i8* %94, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%96 = icmp ne i32 %95, 0
br i1 %96, label %97, label %109
97: ; preds = %93
%98 = load i8*, i8** %12
%99 = call i32 @strcasecmp(i8* %98, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
%100 = icmp ne i32 %99, 0
br i1 %100, label %101, label %109
101: ; preds = %97
%102 = load i8*, i8** %12
%103 = call i32 @strcasecmp(i8* %102, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0))
%104 = icmp ne i32 %103, 0
br i1 %104, label %105, label %109
105: ; preds = %101
%106 = load i8*, i8** %12
%107 = call i32 @strcasecmp(i8* %106, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0))
%108 = icmp ne i32 %107, 0
br i1 %108, label %223, label %109
109: ; preds = %105, %101, %97, %93, %89, %85, %81, %77, %25
br label %110
110: ; preds = %114, %109
%111 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%112 = call i32* @fopen(i8* %111, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0))
store i32* %112, i32** %16
%113 = icmp ne i32* %112, null
br i1 %113, label %114, label %117
114: ; preds = %110
%115 = load i32*, i32** %16
%116 = call i32 @fclose(i32* %115)
br label %110
117: ; preds = %110
%118 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%119 = call i32 @ensureValid(i8* %118, i32* %20, i32* %21)
%120 = icmp ne i32 %119, 0
br i1 %120, label %123, label %121
121: ; preds = %117
%122 = call i32 @exit(i32 0)
unreachable
123: ; preds = %117
%124 = call i32 (...) @rand()
%125 = srem i32 %124, 3
%126 = mul nsw i32 %125, 1
store i32 %126, i32* %19
%127 = load i32, i32* %19
%128 = icmp eq i32 %127, 0
br i1 %128, label %129, label %149
129: ; preds = %123
%130 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%131 = call i32 (...) @rand()
%132 = load i32, i32* %20
%133 = srem i32 %131, %132
%134 = sub nsw i32 %133, 50
%135 = call i32 (...) @rand()
%136 = load i32, i32* %21
%137 = srem i32 %135, %136
%138 = sub nsw i32 %137, 50
%139 = load i8**, i8*** %5
%140 = getelementptr inbounds i8*, i8** %139, i64 2
%141 = load i8*, i8** %140
%142 = load i8**, i8*** %5
%143 = getelementptr inbounds i8*, i8** %142, i64 1
%144 = load i8*, i8** %143
%145 = load i8**, i8*** %5
%146 = getelementptr inbounds i8*, i8** %145, i64 1
%147 = load i8*, i8** %146
%148 = call i32 (i8*, i8*, ...) @sprintf(i8* %130, i8* getelementptr inbounds ([98 x i8], [98 x i8]* @.str.16, i64 0, i64 0), i32 %134, i32 %138, i8* %141, i8* %144, i8* %147)
br label %193
149: ; preds = %123
%150 = load i32, i32* %19
%151 = icmp eq i32 %150, 1
br i1 %151, label %152, label %172
152: ; preds = %149
%153 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%154 = call i32 (...) @rand()
%155 = load i32, i32* %20
%156 = srem i32 %154, %155
%157 = sub nsw i32 %156, 50
%158 = call i32 (...) @rand()
%159 = load i32, i32* %21
%160 = srem i32 %158, %159
%161 = sub nsw i32 %160, 50
%162 = load i8**, i8*** %5
%163 = getelementptr inbounds i8*, i8** %162, i64 2
%164 = load i8*, i8** %163
%165 = load i8**, i8*** %5
%166 = getelementptr inbounds i8*, i8** %165, i64 1
%167 = load i8*, i8** %166
%168 = load i8**, i8*** %5
%169 = getelementptr inbounds i8*, i8** %168, i64 1
%170 = load i8*, i8** %169
%171 = call i32 (i8*, i8*, ...) @sprintf(i8* %153, i8* getelementptr inbounds ([98 x i8], [98 x i8]* @.str.16, i64 0, i64 0), i32 %157, i32 %161, i8* %164, i8* %167, i8* %170)
br label %192
172: ; preds = %149
%173 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%174 = call i32 (...) @rand()
%175 = load i32, i32* %20
%176 = srem i32 %174, %175
%177 = sub nsw i32 %176, 50
%178 = call i32 (...) @rand()
%179 = load i32, i32* %21
%180 = srem i32 %178, %179
%181 = sub nsw i32 %180, 50
%182 = load i8**, i8*** %5
%183 = getelementptr inbounds i8*, i8** %182, i64 2
%184 = load i8*, i8** %183
%185 = load i8**, i8*** %5
%186 = getelementptr inbounds i8*, i8** %185, i64 1
%187 = load i8*, i8** %186
%188 = load i8**, i8*** %5
%189 = getelementptr inbounds i8*, i8** %188, i64 1
%190 = load i8*, i8** %189
%191 = call i32 (i8*, i8*, ...) @sprintf(i8* %173, i8* getelementptr inbounds ([98 x i8], [98 x i8]* @.str.16, i64 0, i64 0), i32 %177, i32 %181, i8* %184, i8* %187, i8* %190)
br label %192
192: ; preds = %172, %152
br label %193
193: ; preds = %192, %129
%194 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%195 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.17, i64 0, i64 0), i8* %194)
%196 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%197 = call i32 @system(i8* %196)
%198 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%199 = call i32 @ensureValid(i8* %198, i32* %20, i32* %21)
%200 = icmp ne i32 %199, 0
br i1 %200, label %203, label %201
201: ; preds = %193
%202 = call i32 @exit(i32 0)
unreachable
203: ; preds = %193
%204 = call i32 (...) @rand()
%205 = srem i32 %204, 2
%206 = icmp eq i32 %205, 0
br i1 %206, label %207, label %210
207: ; preds = %203
%208 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%209 = call i32 @system(i8* %208)
br label %213
210: ; preds = %203
%211 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%212 = call i32 @system(i8* %211)
br label %213
213: ; preds = %210, %207
%214 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%215 = call i32 @ensureValid(i8* %214, i32* %20, i32* %21)
%216 = icmp ne i32 %215, 0
br i1 %216, label %219, label %217
217: ; preds = %213
%218 = call i32 @exit(i32 0)
unreachable
219: ; preds = %213
%220 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%221 = call i32 @system(i8* %220)
%222 = call i32 @system(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.18, i64 0, i64 0))
br label %223
223: ; preds = %24, %219, %105
%224 = load i32, i32* %3
ret i32 %224
}

LLVM IR (-O2):
@.str = [12 x i8] c"data/%s.jpg\00"
@.str.1 = [40 x i8] c"/home/jrising/tmp/tapest/%s/bgfull2.jpg\00"
@.str.2 = [40 x i8] c"/home/jrising/tmp/tapest/%s/bgfull3.jpg\00"
@.str.3 = [101 x i8] c"convert -modulate 99 /home/jrising/tmp/tapest/%s/bgfull2.jpg /home/jrising/tmp/tapest/%s/bgfull3.jpg\00"
@.str.4 = [83 x i8] c"mv /home/jrising/tmp/tapest/%s/bgfull2.jpg /home/jrising/tmp/tapest/%s/bgfull3.jpg\00"
@.str.5 = [55 x i8] c"mv /home/jrising/tmp/tapest/%s/bgfull3.jpg data/%s.jpg\00"
@.str.6 = [5 x i8] c"jpeg\00"
@.str.7 = [5 x i8] c".jpg\00"
@.str.8 = [5 x i8] c".gif\00"
@.str.9 = [5 x i8] c"tiff\00"
@.str.10 = [5 x i8] c".ppm\00"
@.str.11 = [5 x i8] c".bmp\00"
@.str.12 = [5 x i8] c"pict\00"
@.str.13 = [5 x i8] c".pnm\00"
@.str.14 = [5 x i8] c".png\00"
@.str.15 = [2 x i8] c"r\00"
@.str.16 = [98 x i8] c"composite -compose atop -geometry +%d+%d \22%s\22 data/%s.jpg /home/jrising/tmp/tapest/%s/bgfull2.jpg\00"
@.str.17 = [4 x i8] c"%s\0A\00"
@.str.18 = [36 x i8] c"xli -onroot -quiet -fork bgfull.gif\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = alloca [1024 x i8]
%6 = alloca [1024 x i8]
%7 = alloca [1024 x i8]
%8 = alloca [1024 x i8]
%9 = alloca [1024 x i8]
%10 = alloca i32
%11 = alloca i32
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%19 = bitcast i32* %10 to i8*
store i32 0, i32* %10
%20 = bitcast i32* %11 to i8*
store i32 0, i32* %11
%21 = icmp eq i32 %0, 3
br i1 %21, label %22, label %142
22: ; preds = %2
%23 = getelementptr inbounds i8*, i8** %1, i64 1
%24 = load i8*, i8** %23
%25 = call i32 (i8*, i8*, ...) @sprintf(i8* %12, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %24)
%26 = load i8*, i8** %23
%27 = call i32 (i8*, i8*, ...) @sprintf(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i8* %26)
%28 = load i8*, i8** %23
%29 = call i32 (i8*, i8*, ...) @sprintf(i8* %14, i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i8* %28)
%30 = load i8*, i8** %23
%31 = call i32 (i8*, i8*, ...) @sprintf(i8* %15, i8* dereferenceable(1) getelementptr inbounds ([101 x i8], [101 x i8]* @.str.3, i64 0, i64 0), i8* %30, i8* %30)
%32 = load i8*, i8** %23
%33 = call i32 (i8*, i8*, ...) @sprintf(i8* %16, i8* dereferenceable(1) getelementptr inbounds ([83 x i8], [83 x i8]* @.str.4, i64 0, i64 0), i8* %32, i8* %32)
%34 = load i8*, i8** %23
%35 = call i32 (i8*, i8*, ...) @sprintf(i8* %17, i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.5, i64 0, i64 0), i8* %34)
%36 = getelementptr inbounds i8*, i8** %1, i64 2
%37 = load i8*, i8** %36
%38 = tail call i32 @strlen(i8* %37)
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %37, i64 %39
%41 = getelementptr inbounds i8, i8* %40, i64 -4
%42 = tail call i32 @time(i32* null)
%43 = tail call i32 @srand(i32 %42)
%44 = tail call i32 @strcasecmp(i8* %41, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%45 = icmp eq i32 %44, 0
br i1 %45, label %70, label %46
46: ; preds = %22
%47 = tail call i32 @strcasecmp(i8* %41, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%48 = icmp eq i32 %47, 0
br i1 %48, label %70, label %49
49: ; preds = %46
%50 = tail call i32 @strcasecmp(i8* %41, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%51 = icmp eq i32 %50, 0
br i1 %51, label %70, label %52
52: ; preds = %49
%53 = tail call i32 @strcasecmp(i8* %41, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%54 = icmp eq i32 %53, 0
br i1 %54, label %70, label %55
55: ; preds = %52
%56 = tail call i32 @strcasecmp(i8* %41, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%57 = icmp eq i32 %56, 0
br i1 %57, label %70, label %58
58: ; preds = %55
%59 = tail call i32 @strcasecmp(i8* %41, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%60 = icmp eq i32 %59, 0
br i1 %60, label %70, label %61
61: ; preds = %58
%62 = tail call i32 @strcasecmp(i8* %41, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
%63 = icmp eq i32 %62, 0
br i1 %63, label %70, label %64
64: ; preds = %61
%65 = tail call i32 @strcasecmp(i8* %41, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0))
%66 = icmp eq i32 %65, 0
br i1 %66, label %70, label %67
67: ; preds = %64
%68 = tail call i32 @strcasecmp(i8* %41, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0))
%69 = icmp eq i32 %68, 0
br i1 %69, label %70, label %142
70: ; preds = %67, %64, %61, %58, %55, %52, %49, %46, %22
%71 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0))
%72 = icmp eq i32* %71, null
br i1 %72, label %78, label %73
73: ; preds = %70, %73
%74 = phi i32* [ %76, %73 ], [ %71, %70 ]
%75 = tail call i32 @fclose(i32* %74)
%76 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0))
%77 = icmp eq i32* %76, null
br i1 %77, label %78, label %73
78: ; preds = %73, %70
%79 = call i32 @ensureValid(i8* %12, i32* %10, i32* %11)
%80 = icmp eq i32 %79, 0
br i1 %80, label %81, label %83
81: ; preds = %78
%82 = call i32 @exit(i32 0)
unreachable
83: ; preds = %78
%84 = call i32 (...) @rand()
%85 = srem i32 %84, 3
switch i32 %85, label %110 [
i32 0, label %86
i32 1, label %98
]
86: ; preds = %83
%87 = call i32 (...) @rand()
%88 = load i32, i32* %10
%89 = srem i32 %87, %88
%90 = add nsw i32 %89, -50
%91 = call i32 (...) @rand()
%92 = load i32, i32* %11
%93 = srem i32 %91, %92
%94 = add nsw i32 %93, -50
%95 = load i8*, i8** %36
%96 = load i8*, i8** %23
%97 = call i32 (i8*, i8*, ...) @sprintf(i8* %18, i8* dereferenceable(1) getelementptr inbounds ([98 x i8], [98 x i8]* @.str.16, i64 0, i64 0), i32 %90, i32 %94, i8* %95, i8* %96, i8* %96)
br label %122
98: ; preds = %83
%99 = call i32 (...) @rand()
%100 = load i32, i32* %10
%101 = srem i32 %99, %100
%102 = add nsw i32 %101, -50
%103 = call i32 (...) @rand()
%104 = load i32, i32* %11
%105 = srem i32 %103, %104
%106 = add nsw i32 %105, -50
%107 = load i8*, i8** %36
%108 = load i8*, i8** %23
%109 = call i32 (i8*, i8*, ...) @sprintf(i8* %18, i8* dereferenceable(1) getelementptr inbounds ([98 x i8], [98 x i8]* @.str.16, i64 0, i64 0), i32 %102, i32 %106, i8* %107, i8* %108, i8* %108)
br label %122
110: ; preds = %83
%111 = call i32 (...) @rand()
%112 = load i32, i32* %10
%113 = srem i32 %111, %112
%114 = add nsw i32 %113, -50
%115 = call i32 (...) @rand()
%116 = load i32, i32* %11
%117 = srem i32 %115, %116
%118 = add nsw i32 %117, -50
%119 = load i8*, i8** %36
%120 = load i8*, i8** %23
%121 = call i32 (i8*, i8*, ...) @sprintf(i8* %18, i8* dereferenceable(1) getelementptr inbounds ([98 x i8], [98 x i8]* @.str.16, i64 0, i64 0), i32 %114, i32 %118, i8* %119, i8* %120, i8* %120)
br label %122
122: ; preds = %98, %110, %86
%123 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.17, i64 0, i64 0), i8* %18)
%124 = call i32 @system(i8* %18)
%125 = call i32 @ensureValid(i8* %13, i32* %10, i32* %11)
%126 = icmp eq i32 %125, 0
br i1 %126, label %127, label %129
127: ; preds = %122
%128 = call i32 @exit(i32 0)
unreachable
129: ; preds = %122
%130 = call i32 (...) @rand()
%131 = and i32 %130, 1
%132 = icmp eq i32 %131, 0
%133 = select i1 %132, i8* %15, i8* %16
%134 = call i32 @system(i8* %133)
%135 = call i32 @ensureValid(i8* %14, i32* %10, i32* %11)
%136 = icmp eq i32 %135, 0
br i1 %136, label %137, label %139
137: ; preds = %129
%138 = call i32 @exit(i32 0)
unreachable
139: ; preds = %129
%140 = call i32 @system(i8* %17)
%141 = call i32 @system(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.18, i64 0, i64 0))
br label %142
142: ; preds = %67, %139, %2
ret i32 0
}