#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*/ EXIT_FAILURE;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ *popen(char *, char *);
int scanf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int strlen(char *);
FILE *OpenImageFile(char *fileName, char *mode, char *fpType) {
  FILE *fp;
  char *fName, fNameBuf[256], str[256], overwrite;
  switch (mode[0]) {
  case 'r':
    if ((strlen(fileName) > 3 &&
         !strcmp(fileName + strlen(fileName) - 3, ".gz"))) {
      sprintf(str, "zcat -f %s", fileName);
      *fpType = 'p';
      return (popen(str, "r"));
    }
    *fpType = 'f';
    return (fopen(fileName, "r"));
    break;
  case 'w':
    strcpy(fNameBuf, fileName);
    while (1) {
      if (fNameBuf[0] == '!') {
        fName = fNameBuf + 1;
        overwrite = 'y';
      } else {
        fName = fNameBuf;
        overwrite = 'n';
      }
      if (overwrite == 'n' && (fp = fopen(fName, "r")) != NULL) {
        fclose(fp);
        fprintf(stderr, "Warning (OpenImageFile): file %s exists.\n", fName);
        fprintf(stderr,
                "Type \"y\" to overwrite or an alternative file name: ");
        if (scanf("%s", str) != 1) {
          fprintf(stderr,
                  "Error obtaining the file name or overwrite option!\n");
          exit(EXIT_FAILURE);
        }
        if (!strcmp("y", str))
          break;
        else
          strcpy(fNameBuf, str);
      } else
        break;
    }
    if ((strlen(fName) > 3 && !strcmp(fName + strlen(fName) - 3, ".gz"))) {
      sprintf(str, "gzip - > %s", fName);
      *fpType = 'p';
      fp = popen(str, "w");
      if (fp == NULL)
        strerror(errno);
      return fp;
    }
    if (!strcmp(fName, "x11")) {
      sprintf(str, "%s", "xv -");
      *fpType = 'p';
      return (popen(str, "w"));
    }
    *fpType = 'f';
    if ((fp = fopen(fName, "w")) == NULL) {
      strerror(errno);
    }
    return fp;
    break;
  }
  return (NULL);
}


x86 assembly (clang, -O0):
<OpenImageFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x250,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x238(%rbp)
sub    $0x72,%eax
je     11f6 <OpenImageFile+0x46>
jmp    11e2 <OpenImageFile+0x32>
mov    -0x238(%rbp),%eax
sub    $0x77,%eax
je     129b <OpenImageFile+0xeb>
jmp    1511 <OpenImageFile+0x361>
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x3,%eax
jle    127b <OpenImageFile+0xcb>
mov    -0x10(%rbp),%rax
mov    %rax,-0x240(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x240(%rbp),%rdi
cltq
add    %rax,%rdi
add    $0xfffffffffffffffd,%rdi
lea    0xdcd(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    127b <OpenImageFile+0xcb>
lea    -0x230(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xdb1(%rip),%rsi
call   10b0 <sprintf@plt>
mov    -0x20(%rbp),%rax
movb   $0x70,(%rax)
lea    -0x230(%rbp),%rdi
lea    0xda2(%rip),%rsi
call   1090 <popen@plt>
mov    %rax,-0x8(%rbp)
jmp    1519 <OpenImageFile+0x369>
mov    -0x20(%rbp),%rax
movb   $0x66,(%rax)
mov    -0x10(%rbp),%rdi
lea    0xd82(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x8(%rbp)
jmp    1519 <OpenImageFile+0x369>
lea    -0x130(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
movsbl -0x130(%rbp),%eax
cmp    $0x21,%eax
jne    12d6 <OpenImageFile+0x126>
lea    -0x130(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
movb   $0x79,-0x231(%rbp)
jmp    12e8 <OpenImageFile+0x138>
lea    -0x130(%rbp),%rax
mov    %rax,-0x30(%rbp)
movb   $0x6e,-0x231(%rbp)
movsbl -0x231(%rbp),%eax
cmp    $0x6e,%eax
jne    13cb <OpenImageFile+0x21b>
mov    -0x30(%rbp),%rdi
lea    0xd0c(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     13cb <OpenImageFile+0x21b>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
mov    0x2cba(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rdx
lea    0xcde(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2c9f(%rip),%rax
mov    (%rax),%edi
lea    0xcf1(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
lea    -0x230(%rbp),%rsi
lea    0xd4f(%rip),%rdi
call   1080 <scanf@plt>
cmp    $0x1,%eax
je     1392 <OpenImageFile+0x1e2>
mov    0x2c6c(%rip),%rax
mov    (%rax),%edi
lea    0xcf2(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2c45(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
lea    -0x230(%rbp),%rsi
lea    0xd03(%rip),%rdi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    13b3 <OpenImageFile+0x203>
jmp    13d5 <OpenImageFile+0x225>
lea    -0x130(%rbp),%rdi
lea    -0x230(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    13d0 <OpenImageFile+0x220>
jmp    13d5 <OpenImageFile+0x225>
jmp    12ab <OpenImageFile+0xfb>
mov    -0x30(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x3,%eax
jle    147b <OpenImageFile+0x2cb>
mov    -0x30(%rbp),%rax
mov    %rax,-0x248(%rbp)
mov    -0x30(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x248(%rbp),%rdi
cltq
add    %rax,%rdi
add    $0xfffffffffffffffd,%rdi
lea    0xbee(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    147b <OpenImageFile+0x2cb>
lea    -0x230(%rbp),%rdi
mov    -0x30(%rbp),%rdx
lea    0xc73(%rip),%rsi
call   10b0 <sprintf@plt>
mov    -0x20(%rbp),%rax
movb   $0x70,(%rax)
lea    -0x230(%rbp),%rdi
lea    0xc65(%rip),%rsi
call   1090 <popen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    146e <OpenImageFile+0x2be>
mov    0x2b71(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1519 <OpenImageFile+0x369>
mov    -0x30(%rbp),%rdi
lea    0xc2d(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    14d1 <OpenImageFile+0x321>
lea    -0x230(%rbp),%rdi
lea    0xc0c(%rip),%rsi
lea    0xc0e(%rip),%rdx
call   10b0 <sprintf@plt>
mov    -0x20(%rbp),%rax
movb   $0x70,(%rax)
lea    -0x230(%rbp),%rdi
lea    0xbee(%rip),%rsi
call   1090 <popen@plt>
mov    %rax,-0x8(%rbp)
jmp    1519 <OpenImageFile+0x369>
mov    -0x20(%rbp),%rax
movb   $0x66,(%rax)
mov    -0x30(%rbp),%rdi
lea    0xbce(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1504 <OpenImageFile+0x354>
mov    0x2adb(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1519 <OpenImageFile+0x369>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x250,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<OpenImageFile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x218,%rsp
mov    %rdx,%r14
mov    %rdi,%rbp
movsbl (%rsi),%eax
cmp    $0x77,%eax
je     122f <OpenImageFile+0x7f>
cmp    $0x72,%eax
jne    13ed <OpenImageFile+0x23d>
mov    %rbp,%rdi
call   1050 <strlen@plt>
cmp    $0x4,%eax
jl     120b <OpenImageFile+0x5b>
mov    %rbp,%rdi
call   1050 <strlen@plt>
cltq
lea    (%rax,%rbp,1),%rdi
add    $0xfffffffffffffffd,%rdi
lea    0xe02(%rip),%rsi
call   1060 <strcmp@plt>
test   %eax,%eax
je     1384 <OpenImageFile+0x1d4>
movb   $0x66,(%r14)
lea    0xdf9(%rip),%rsi
mov    %rbp,%rdi
add    $0x218,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    10a0 <fopen@plt>
lea    0x110(%rsp),%rbx
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1030 <strcpy@plt>
lea    0x111(%rsp),%rbp
cmpb   $0x21,0x110(%rsp)
21
je     1303 <OpenImageFile+0x153>
mov    %r14,0x8(%rsp)
lea    0xdab(%rip),%r12
mov    0x2d75(%rip),%r13
lea    0xdc9(%rip),%rbp
lea    0xe33(%rip),%r14
lea    0x10(%rsp),%r15
xchg   %ax,%ax
mov    %rbx,%rdi
mov    %r12,%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     12fb <OpenImageFile+0x14b>
mov    %rax,%rdi
call   1040 <fclose@plt>
mov    0x0(%r13),%edi
lea    0xd6e(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x0(%r13),%edi
mov    %rbp,%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1080 <scanf@plt>
cmp    $0x1,%eax
jne    1401 <OpenImageFile+0x251>
cmpw   $0x79,0x10(%rsp)
je     12fb <OpenImageFile+0x14b>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
cmpb   $0x21,0x110(%rsp)
21
jne    1280 <OpenImageFile+0xd0>
mov    0x8(%rsp),%r14
lea    0x111(%rsp),%rbp
jmp    1303 <OpenImageFile+0x153>
mov    %rbx,%rbp
mov    0x8(%rsp),%r14
mov    %rbp,%rdi
call   1050 <strlen@plt>
cmp    $0x4,%eax
jl     1332 <OpenImageFile+0x182>
mov    %rbp,%rdi
call   1050 <strlen@plt>
cltq
lea    (%rax,%rbp,1),%rdi
add    $0xfffffffffffffffd,%rdi
lea    0xcd7(%rip),%rsi
call   1060 <strcmp@plt>
test   %eax,%eax
je     13b0 <OpenImageFile+0x200>
lea    0xd78(%rip),%rsi
mov    %rbp,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
je     1363 <OpenImageFile+0x1b3>
movb   $0x66,(%r14)
lea    0xd5f(%rip),%rsi
mov    %rbp,%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
jne    13ef <OpenImageFile+0x23f>
jmp    13df <OpenImageFile+0x22f>
lea    0xd4b(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
movb   $0x70,(%r14)
lea    0xd2d(%rip),%rsi
jmp    13a6 <OpenImageFile+0x1f6>
lea    0xc79(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %rbp,%rdx
call   10b0 <sprintf@plt>
movb   $0x70,(%r14)
lea    0xc69(%rip),%rsi
mov    %rbx,%rdi
call   1090 <popen@plt>
jmp    13ef <OpenImageFile+0x23f>
lea    0xcec(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %rbp,%rdx
call   10b0 <sprintf@plt>
movb   $0x70,(%r14)
lea    0xcdd(%rip),%rsi
mov    %rbx,%rdi
call   1090 <popen@plt>
test   %rax,%rax
jne    13ef <OpenImageFile+0x23f>
mov    0x2bf2(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
xor    %eax,%eax
add    $0x218,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x0(%r13),%edi
lea    0xc63(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x2bb6(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c".gz\00"
@.str.1 = [11 x i8] c"zcat -f %s\00"
@.str.2 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.3 = [42 x i8] c"Warning (OpenImageFile): file %s exists.\0A\00"
@.str.4 = [52 x i8] c"Type \22y\22 to overwrite or an alternative file name: \00"
@.str.5 = [3 x i8] c"%s\00"
@.str.6 = [52 x i8] c"Error obtaining the file name or overwrite option!\0A\00"
@EXIT_FAILURE = global i32 0
@.str.7 = [2 x i8] c"y\00"
@.str.8 = [12 x i8] c"gzip - > %s\00"
@.str.9 = [2 x i8] c"w\00"
@errno = global i32 0
@.str.10 = [4 x i8] c"x11\00"
@.str.11 = [5 x i8] c"xv -\00"
define i32* @OpenImageFile(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca [256 x i8]
%11 = alloca [256 x i8]
%12 = alloca i8
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%13 = load i8*, i8** %6
%14 = getelementptr inbounds i8, i8* %13, i64 0
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
switch i32 %16, label %138 [
i32 114, label %17
i32 119, label %41
]
17: ; preds = %3
%18 = load i8*, i8** %5
%19 = call i32 @strlen(i8* %18)
%20 = icmp sgt i32 %19, 3
br i1 %20, label %21, label %37
21: ; preds = %17
%22 = load i8*, i8** %5
%23 = load i8*, i8** %5
%24 = call i32 @strlen(i8* %23)
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %22, i64 %25
%27 = getelementptr inbounds i8, i8* %26, i64 -3
%28 = call i32 @strcmp(i8* %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%29 = icmp ne i32 %28, 0
br i1 %29, label %37, label %30
30: ; preds = %21
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%32 = load i8*, i8** %5
%33 = call i32 @sprintf(i8* %31, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %32)
%34 = load i8*, i8** %7
store i8 112, i8* %34
%35 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%36 = call i32* @popen(i8* %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %36, i32** %4
br label %139
37: ; preds = %21, %17
%38 = load i8*, i8** %7
store i8 102, i8* %38
%39 = load i8*, i8** %5
%40 = call i32* @fopen(i8* %39, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %40, i32** %4
br label %139
41: ; preds = %3
%42 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%43 = load i8*, i8** %5
%44 = call i32 @strcpy(i8* %42, i8* %43)
br label %45
45: ; preds = %41, %90
%46 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp eq i32 %48, 33
br i1 %49, label %50, label %53
50: ; preds = %45
%51 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%52 = getelementptr inbounds i8, i8* %51, i64 1
store i8* %52, i8** %9
store i8 121, i8* %12
br label %55
53: ; preds = %45
%54 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
store i8* %54, i8** %9
store i8 110, i8* %12
br label %55
55: ; preds = %53, %50
%56 = load i8, i8* %12
%57 = sext i8 %56 to i32
%58 = icmp eq i32 %57, 110
br i1 %58, label %59, label %89
59: ; preds = %55
%60 = load i8*, i8** %9
%61 = call i32* @fopen(i8* %60, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %61, i32** %8
%62 = icmp ne i32* %61, null
br i1 %62, label %63, label %89
63: ; preds = %59
%64 = load i32*, i32** %8
%65 = call i32 @fclose(i32* %64)
%66 = load i32, i32* @stderr
%67 = load i8*, i8** %9
%68 = call i32 (i32, i8*, ...) @fprintf(i32 %66, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i8* %67)
%69 = load i32, i32* @stderr
%70 = call i32 (i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.4, i64 0, i64 0))
%71 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%72 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %71)
%73 = icmp ne i32 %72, 1
br i1 %73, label %74, label %79
74: ; preds = %63
%75 = load i32, i32* @stderr
%76 = call i32 (i32, i8*, ...) @fprintf(i32 %75, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.6, i64 0, i64 0))
%77 = load i32, i32* @EXIT_FAILURE
%78 = call i32 @exit(i32 %77)
unreachable
79: ; preds = %63
%80 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%81 = call i32 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8* %80)
%82 = icmp ne i32 %81, 0
br i1 %82, label %84, label %83
83: ; preds = %79
br label %91
84: ; preds = %79
%85 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%86 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%87 = call i32 @strcpy(i8* %85, i8* %86)
br label %88
88: ; preds = %84
br label %90
89: ; preds = %59, %55
br label %91
90: ; preds = %88
br label %45
91: ; preds = %89, %83
%92 = load i8*, i8** %9
%93 = call i32 @strlen(i8* %92)
%94 = icmp sgt i32 %93, 3
br i1 %94, label %95, label %118
95: ; preds = %91
%96 = load i8*, i8** %9
%97 = load i8*, i8** %9
%98 = call i32 @strlen(i8* %97)
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds i8, i8* %96, i64 %99
%101 = getelementptr inbounds i8, i8* %100, i64 -3
%102 = call i32 @strcmp(i8* %101, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%103 = icmp ne i32 %102, 0
br i1 %103, label %118, label %104
104: ; preds = %95
%105 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%106 = load i8*, i8** %9
%107 = call i32 @sprintf(i8* %105, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i8* %106)
%108 = load i8*, i8** %7
store i8 112, i8* %108
%109 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%110 = call i32* @popen(i8* %109, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
store i32* %110, i32** %8
%111 = load i32*, i32** %8
%112 = icmp eq i32* %111, null
br i1 %112, label %113, label %116
113: ; preds = %104
%114 = load i32, i32* @errno
%115 = call i32 @strerror(i32 %114)
br label %116
116: ; preds = %113, %104
%117 = load i32*, i32** %8
store i32* %117, i32** %4
br label %139
118: ; preds = %95, %91
%119 = load i8*, i8** %9
%120 = call i32 @strcmp(i8* %119, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
%121 = icmp ne i32 %120, 0
br i1 %121, label %128, label %122
122: ; preds = %118
%123 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%124 = call i32 @sprintf(i8* %123, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%125 = load i8*, i8** %7
store i8 112, i8* %125
%126 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%127 = call i32* @popen(i8* %126, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
store i32* %127, i32** %4
br label %139
128: ; preds = %118
%129 = load i8*, i8** %7
store i8 102, i8* %129
%130 = load i8*, i8** %9
%131 = call i32* @fopen(i8* %130, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
store i32* %131, i32** %8
%132 = icmp eq i32* %131, null
br i1 %132, label %133, label %136
133: ; preds = %128
%134 = load i32, i32* @errno
%135 = call i32 @strerror(i32 %134)
br label %136
136: ; preds = %133, %128
%137 = load i32*, i32** %8
store i32* %137, i32** %4
br label %139
138: ; preds = %3
store i32* null, i32** %4
br label %139
139: ; preds = %138, %136, %122, %116, %37, %30
%140 = load i32*, i32** %4
ret i32* %140
}

LLVM IR (-O2):
@.str = [4 x i8] c".gz\00"
@.str.1 = [11 x i8] c"zcat -f %s\00"
@.str.2 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.3 = [42 x i8] c"Warning (OpenImageFile): file %s exists.\0A\00"
@.str.4 = [52 x i8] c"Type \22y\22 to overwrite or an alternative file name: \00"
@.str.5 = [3 x i8] c"%s\00"
@.str.6 = [52 x i8] c"Error obtaining the file name or overwrite option!\0A\00"
@EXIT_FAILURE = global i32 0
@.str.8 = [12 x i8] c"gzip - > %s\00"
@.str.9 = [2 x i8] c"w\00"
@errno = global i32 0
@.str.10 = [4 x i8] c"x11\00"
@.str.11 = [5 x i8] c"xv -\00"
define i32* @OpenImageFile(i8* %0, i8* nocapture %1, i8* nocapture writeonly %2) {
%4 = alloca [256 x i8]
%5 = alloca [256 x i8]
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%8 = load i8, i8* %1
%9 = sext i8 %8 to i32
switch i32 %9, label %85 [
i32 114, label %10
i32 119, label %25
]
10: ; preds = %3
%11 = tail call i32 @strlen(i8* %0)
%12 = icmp sgt i32 %11, 3
br i1 %12, label %13, label %23
13: ; preds = %10
%14 = tail call i32 @strlen(i8* %0)
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %0, i64 %15
%17 = getelementptr inbounds i8, i8* %16, i64 -3
%18 = tail call i32 @strcmp(i8* %17, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %13
%21 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %0)
store i8 112, i8* %2
%22 = call i32* @popen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %85
23: ; preds = %13, %10
store i8 102, i8* %2
%24 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %85
25: ; preds = %3
%26 = call i32 @strcpy(i8* %6, i8* %0)
%27 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 1
%28 = load i8, i8* %6
%29 = icmp eq i8 %28, 33
br i1 %29, label %55, label %30
30: ; preds = %25
%31 = bitcast [256 x i8]* %5 to i16*
br label %32
32: ; preds = %30, %51
%33 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%34 = icmp eq i32* %33, null
br i1 %34, label %55, label %35
35: ; preds = %32
%36 = call i32 @fclose(i32* %33)
%37 = load i32, i32* @stderr
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i8* %6)
%39 = load i32, i32* @stderr
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.4, i64 0, i64 0))
%41 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %7)
%42 = icmp eq i32 %41, 1
br i1 %42, label %48, label %43
43: ; preds = %35
%44 = load i32, i32* @stderr
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.6, i64 0, i64 0))
%46 = load i32, i32* @EXIT_FAILURE
%47 = call i32 @exit(i32 %46)
unreachable
48: ; preds = %35
%49 = load i16, i16* %31
%50 = icmp eq i16 %49, 121
br i1 %50, label %55, label %51
51: ; preds = %48
%52 = call i32 @strcpy(i8* %6, i8* %7)
%53 = load i8, i8* %6
%54 = icmp eq i8 %53, 33
br i1 %54, label %55, label %32
55: ; preds = %48, %32, %51, %25
%56 = phi i8* [ %27, %25 ], [ %27, %51 ], [ %6, %32 ], [ %6, %48 ]
%57 = call i32 @strlen(i8* %56)
%58 = icmp sgt i32 %57, 3
br i1 %58, label %59, label %73
59: ; preds = %55
%60 = call i32 @strlen(i8* %56)
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %56, i64 %61
%63 = getelementptr inbounds i8, i8* %62, i64 -3
%64 = call i32 @strcmp(i8* %63, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%65 = icmp eq i32 %64, 0
br i1 %65, label %66, label %73
66: ; preds = %59
%67 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i8* %56)
store i8 112, i8* %2
%68 = call i32* @popen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%69 = icmp eq i32* %68, null
br i1 %69, label %70, label %85
70: ; preds = %66
%71 = load i32, i32* @errno
%72 = call i32 @strerror(i32 %71)
br label %85
73: ; preds = %59, %55
%74 = call i32 @strcmp(i8* %56, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
%75 = icmp eq i32 %74, 0
br i1 %75, label %76, label %79
76: ; preds = %73
%77 = call i8* bitcast (i32 (i8*, i8*)* @strcpy to i8* (i8*, i8*)*)(i8* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
store i8 112, i8* %2
%78 = call i32* @popen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
br label %85
79: ; preds = %73
store i8 102, i8* %2
%80 = call i32* @fopen(i8* %56, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%81 = icmp eq i32* %80, null
br i1 %81, label %82, label %85
82: ; preds = %79
%83 = load i32, i32* @errno
%84 = call i32 @strerror(i32 %83)
br label %85
85: ; preds = %3, %79, %82, %66, %70, %76, %23, %20
%86 = phi i32* [ %78, %76 ], [ %24, %23 ], [ %22, %20 ], [ null, %70 ], [ %68, %66 ], [ null, %82 ], [ %80, %79 ], [ null, %3 ]
ret i32* %86
}