#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fread(char *, int, int, int /*<<< orphan*/ *);
int fwrite(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ remove(char *);
int /*<<< orphan*/ rename(char *, char *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char *argv[]) {
  FILE *inpExe, *outExe;
  char fname[0xff], ftemp[0xff], fbak[0xff];
  char buffer[0xff];
  int bufLen, pos, fcs, recount;
  if (argc > 0) {
    strcpy(fname, argv[1]);
    inpExe = fopen(fname, "rb");
    if (inpExe == NULL) {
      printf("Gagal membuka file %s!\n", fname);
      return EXIT_FAILURE;
    }
    strcpy(ftemp, fname);
    strcat(ftemp, ".tmp");
    outExe = fopen(ftemp, "wb");
    if (outExe == NULL) {
      printf("Gagal membuat file %s!\n", ftemp);
      return EXIT_FAILURE;
    }
    rewind(inpExe);
    fcs = 0;
    recount = 0;
    while (!feof(inpExe)) {
      bufLen = fread(buffer, 1, 0xff, inpExe);
      for (pos = 0; pos < bufLen - 3; pos++) {
        if ((buffer[pos] == 0x55) && (buffer[pos + 1] == 0x50) &&
            (buffer[pos + 2] == 0x58)) {
          if (buffer[pos + 3] == 0x30) {
            memcpy(&buffer[pos], "PKT1", 4);
            printf("Mengganti UPX0 di posisi 0x%.8x\n", fcs + pos);
            recount++;
          } else if (buffer[pos + 3] == 0x31) {
            memcpy(&buffer[pos], "PKT0", 4);
            printf("Mengganti UPX1 di posisi 0x%.8x\n", fcs + pos);
            recount++;
          }
        }
      }
      fcs += bufLen;
      bufLen = fwrite(buffer, 1, bufLen, outExe);
    }
    fclose(outExe);
    fclose(inpExe);
    if (recount > 0) {
      printf("%d string berhasil diganti!\n", recount);
      strcpy(fbak, fname);
      strcat(fbak, ".bak");
      remove(fbak);
      printf("Membuat file backup \"%s\"...\n", fbak);
      rename(fname, fbak);
      printf("Mengganti file asli \"%s\"...\n", fname);
      rename(ftemp, fname);
    } else {
      printf("Hmm, tidak ada string yang diganti!\n");
      remove(ftemp);
    }
    printf("Selesai!\n");
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    1589 <main+0x3c9>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1040 <strcpy@plt>
lea    -0x120(%rbp),%rdi
lea    0xdfb(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    123f <main+0x7f>
lea    -0x120(%rbp),%rsi
lea    0xddc(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    0x2dab(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1595 <main+0x3d5>
lea    -0x220(%rbp),%rdi
lea    -0x120(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x220(%rbp),%rdi
lea    0xdbb(%rip),%rsi
call   10d0 <strcat@plt>
lea    -0x220(%rbp),%rdi
lea    0xdad(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    12ad <main+0xed>
lea    -0x220(%rbp),%rsi
lea    0xd8e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    0x2d3d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1595 <main+0x3d5>
mov    -0x18(%rbp),%rdi
call   1080 <rewind@plt>
movl   $0x0,-0x42c(%rbp)
movl   $0x0,-0x430(%rbp)
mov    -0x18(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    12e8 <main+0x128>
jmp    14a7 <main+0x2e7>
lea    -0x420(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
mov    $0xff,%edx
call   1050 <fread@plt>
mov    %eax,-0x424(%rbp)
movl   $0x0,-0x428(%rbp)
mov    -0x428(%rbp),%eax
mov    -0x424(%rbp),%ecx
sub    $0x3,%ecx
cmp    %ecx,%eax
jge    146f <main+0x2af>
movslq -0x428(%rbp),%rax
movsbl -0x420(%rbp,%rax,1),%eax
ff
cmp    $0x55,%eax
jne    1456 <main+0x296>
mov    -0x428(%rbp),%eax
add    $0x1,%eax
cltq
movsbl -0x420(%rbp,%rax,1),%eax
ff
cmp    $0x50,%eax
jne    1456 <main+0x296>
mov    -0x428(%rbp),%eax
add    $0x2,%eax
cltq
movsbl -0x420(%rbp,%rax,1),%eax
ff
cmp    $0x58,%eax
jne    1456 <main+0x296>
mov    -0x428(%rbp),%eax
add    $0x3,%eax
cltq
movsbl -0x420(%rbp,%rax,1),%eax
ff
cmp    $0x30,%eax
jne    13e5 <main+0x225>
movslq -0x428(%rbp),%rax
lea    -0x420(%rbp),%rdi
add    %rax,%rdi
lea    0xc8e(%rip),%rsi
mov    $0x4,%edx
call   10a0 <memcpy@plt>
mov    -0x42c(%rbp),%esi
add    -0x428(%rbp),%esi
lea    0xc76(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x430(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x430(%rbp)
jmp    1451 <main+0x291>
mov    -0x428(%rbp),%eax
add    $0x3,%eax
cltq
movsbl -0x420(%rbp,%rax,1),%eax
ff
cmp    $0x31,%eax
jne    144c <main+0x28c>
movslq -0x428(%rbp),%rax
lea    -0x420(%rbp),%rdi
add    %rax,%rdi
lea    0xc48(%rip),%rsi
mov    $0x4,%edx
call   10a0 <memcpy@plt>
mov    -0x42c(%rbp),%esi
add    -0x428(%rbp),%esi
lea    0xc30(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x430(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x430(%rbp)
jmp    1451 <main+0x291>
jmp    1456 <main+0x296>
jmp    145b <main+0x29b>
mov    -0x428(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x428(%rbp)
jmp    1312 <main+0x152>
mov    -0x424(%rbp),%eax
add    -0x42c(%rbp),%eax
mov    %eax,-0x42c(%rbp)
lea    -0x420(%rbp),%rdi
mov    -0x424(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
call   10e0 <fwrite@plt>
mov    %eax,-0x424(%rbp)
jmp    12ca <main+0x10a>
mov    -0x20(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1060 <fclose@plt>
cmpl   $0x0,-0x430(%rbp)
jle    1561 <main+0x3a1>
mov    -0x430(%rbp),%esi
lea    0xbb4(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x320(%rbp),%rdi
lea    -0x120(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x320(%rbp),%rdi
lea    0xba9(%rip),%rsi
call   10d0 <strcat@plt>
lea    -0x320(%rbp),%rdi
call   1030 <remove@plt>
lea    -0x320(%rbp),%rsi
lea    0xb8f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x120(%rbp),%rdi
lea    -0x320(%rbp),%rsi
call   10c0 <rename@plt>
lea    -0x120(%rbp),%rsi
lea    0xb84(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x220(%rbp),%rdi
lea    -0x120(%rbp),%rsi
call   10c0 <rename@plt>
jmp    157b <main+0x3bb>
lea    0xb7b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x220(%rbp),%rdi
call   1030 <remove@plt>
lea    0xb86(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    0x2a48(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x428,%rsp
mov    0x2df0(%rip),%rbx
test   %edi,%edi
jle    1467 <main+0x297>
mov    0x8(%rsi),%rsi
lea    0x120(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strcpy@plt>
lea    0xdf5(%rip),%rsi
mov    %rbx,%rdi
call   10c0 <fopen@plt>
test   %rax,%rax
je     131d <main+0x14d>
mov    %rax,%rbx
lea    0x20(%rsp),%rbp
lea    0x120(%rsp),%rsi
mov    %rbp,%rdi
call   1040 <strcpy@plt>
lea    0xde0(%rip),%rsi
mov    %rbp,%rdi
call   10e0 <strcat@plt>
lea    0xdd6(%rip),%rsi
mov    %rbp,%rdi
call   10c0 <fopen@plt>
mov    %rax,0x10(%rsp)
test   %rax,%rax
je     132e <main+0x15e>
mov    %rbx,%rdi
call   1090 <rewind@plt>
mov    %rbx,%rdi
call   10a0 <feof@plt>
movl   $0x0,0xc(%rsp)
test   %eax,%eax
je     134d <main+0x17d>
mov    0x10(%rsp),%rdi
call   1070 <fclose@plt>
mov    %rbx,%rdi
call   1070 <fclose@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
jle    143e <main+0x26e>
lea    0xde2(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0x320(%rsp),%rbp
lea    0x120(%rsp),%rbx
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
lea    0xdd6(%rip),%rsi
mov    %rbp,%rdi
call   10e0 <strcat@plt>
mov    %rbp,%rdi
call   1030 <remove@plt>
lea    0xdc4(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   10d0 <rename@plt>
lea    0xdc5(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0x20(%rsp),%rdi
mov    %rbx,%rsi
call   10d0 <rename@plt>
jmp    1454 <main+0x284>
lea    0xcdf(%rip),%rdi
lea    0x120(%rsp),%rsi
jmp    133a <main+0x16a>
lea    0xcee(%rip),%rdi
lea    0x20(%rsp),%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2c98(%rip),%rbx
jmp    1467 <main+0x297>
lea    0x220(%rsp),%rbp
movl   $0x0,0xc(%rsp)
xor    %r12d,%r12d
mov    %rbx,0x18(%rsp)
jmp    13a4 <main+0x1d4>
nopw   0x0(%rax,%rax,1)
add    %ebx,%r12d
lea    0x220(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
mov    0x10(%rsp),%rcx
call   10f0 <fwrite@plt>
mov    0x18(%rsp),%rbx
mov    %rbx,%rdi
call   10a0 <feof@plt>
test   %eax,%eax
jne    1280 <main+0xb0>
mov    %rbp,%rdi
mov    $0x1,%esi
mov    $0xff,%edx
mov    %rbx,%rcx
call   1060 <fread@plt>
mov    %eax,%ebx
cmp    $0x4,%eax
jl     1370 <main+0x1a0>
lea    -0x3(%rbx),%r13d
mov    %r12d,%r14d
jmp    1402 <main+0x232>
mov    %rbp,%rdi
mov    $0x4,%edx
call   10b0 <memcpy@plt>
mov    %r15,%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1080 <printf@plt>
addl   $0x1,0xc(%rsp)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r14d
add    $0x1,%rbp
add    $0xffffffffffffffff,%r13
je     1370 <main+0x1a0>
cmpb   $0x55,0x0(%rbp)
jne    13f0 <main+0x220>
cmpb   $0x50,0x1(%rbp)
jne    13f0 <main+0x220>
cmpb   $0x58,0x2(%rbp)
jne    13f0 <main+0x220>
movzbl 0x3(%rbp),%eax
lea    0xc1c(%rip),%rsi
lea    0xc1a(%rip),%r15
cmp    $0x30,%al
je     13c9 <main+0x1f9>
cmp    $0x31,%al
jne    13f0 <main+0x220>
lea    0xc2c(%rip),%rsi
lea    0xc2a(%rip),%r15
jmp    13c9 <main+0x1f9>
lea    0xc9e(%rip),%rdi
call   1050 <puts@plt>
lea    0x20(%rsp),%rdi
call   1030 <remove@plt>
mov    0x2b7d(%rip),%rbx
lea    0xca5(%rip),%rdi
call   1050 <puts@plt>
mov    (%rbx),%eax
add    $0x428,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@.str.1 = [24 x i8] c"Gagal membuka file %s!\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [5 x i8] c".tmp\00"
@.str.3 = [3 x i8] c"wb\00"
@.str.4 = [24 x i8] c"Gagal membuat file %s!\0A\00"
@.str.5 = [5 x i8] c"PKT1\00"
@.str.6 = [33 x i8] c"Mengganti UPX0 di posisi 0x%.8x\0A\00"
@.str.7 = [5 x i8] c"PKT0\00"
@.str.8 = [33 x i8] c"Mengganti UPX1 di posisi 0x%.8x\0A\00"
@.str.9 = [29 x i8] c"%d string berhasil diganti!\0A\00"
@.str.10 = [5 x i8] c".bak\00"
@.str.11 = [29 x i8] c"Membuat file backup \22%s\22...\0A\00"
@.str.12 = [29 x i8] c"Mengganti file asli \22%s\22...\0A\00"
@.str.13 = [37 x i8] c"Hmm, tidak ada string yang diganti!\0A\00"
@.str.14 = [10 x i8] c"Selesai!\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca [255 x i8]
%9 = alloca [255 x i8]
%10 = alloca [255 x i8]
%11 = alloca [255 x i8]
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = load i32, i32* %4
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %171
18: ; preds = %2
%19 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @strcpy(i8* %19, i8* %22)
%24 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%25 = call i32* @fopen(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %25, i32** %6
%26 = load i32*, i32** %6
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %32
28: ; preds = %18
%29 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %29)
%31 = load i32, i32* @EXIT_FAILURE
store i32 %31, i32* %3
br label %173
32: ; preds = %18
%33 = getelementptr inbounds [255 x i8], [255 x i8]* %9, i64 0, i64 0
%34 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%35 = call i32 @strcpy(i8* %33, i8* %34)
%36 = getelementptr inbounds [255 x i8], [255 x i8]* %9, i64 0, i64 0
%37 = call i32 @strcat(i8* %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%38 = getelementptr inbounds [255 x i8], [255 x i8]* %9, i64 0, i64 0
%39 = call i32* @fopen(i8* %38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %39, i32** %7
%40 = load i32*, i32** %7
%41 = icmp eq i32* %40, null
br i1 %41, label %42, label %46
42: ; preds = %32
%43 = getelementptr inbounds [255 x i8], [255 x i8]* %9, i64 0, i64 0
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %43)
%45 = load i32, i32* @EXIT_FAILURE
store i32 %45, i32* %3
br label %173
46: ; preds = %32
%47 = load i32*, i32** %6
%48 = call i32 @rewind(i32* %47)
store i32 0, i32* %14
store i32 0, i32* %15
br label %49
49: ; preds = %130, %46
%50 = load i32*, i32** %6
%51 = call i32 @feof(i32* %50)
%52 = icmp ne i32 %51, 0
%53 = xor i1 %52, true
br i1 %53, label %54, label %138
54: ; preds = %49
%55 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 0
%56 = load i32*, i32** %6
%57 = call i32 @fread(i8* %55, i32 1, i32 255, i32* %56)
store i32 %57, i32* %12
store i32 0, i32* %13
br label %58
58: ; preds = %127, %54
%59 = load i32, i32* %13
%60 = load i32, i32* %12
%61 = sub nsw i32 %60, 3
%62 = icmp slt i32 %59, %61
br i1 %62, label %63, label %130
63: ; preds = %58
%64 = load i32, i32* %13
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 %65
%67 = load i8, i8* %66
%68 = sext i8 %67 to i32
%69 = icmp eq i32 %68, 85
br i1 %69, label %70, label %126
70: ; preds = %63
%71 = load i32, i32* %13
%72 = add nsw i32 %71, 1
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 %73
%75 = load i8, i8* %74
%76 = sext i8 %75 to i32
%77 = icmp eq i32 %76, 80
br i1 %77, label %78, label %126
78: ; preds = %70
%79 = load i32, i32* %13
%80 = add nsw i32 %79, 2
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 %81
%83 = load i8, i8* %82
%84 = sext i8 %83 to i32
%85 = icmp eq i32 %84, 88
br i1 %85, label %86, label %126
86: ; preds = %78
%87 = load i32, i32* %13
%88 = add nsw i32 %87, 3
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 %89
%91 = load i8, i8* %90
%92 = sext i8 %91 to i32
%93 = icmp eq i32 %92, 48
br i1 %93, label %94, label %105
94: ; preds = %86
%95 = load i32, i32* %13
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 %96
%98 = call i32 @memcpy(i8* %97, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 4)
%99 = load i32, i32* %14
%100 = load i32, i32* %13
%101 = add nsw i32 %99, %100
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i32 %101)
%103 = load i32, i32* %15
%104 = add nsw i32 %103, 1
store i32 %104, i32* %15
br label %125
105: ; preds = %86
%106 = load i32, i32* %13
%107 = add nsw i32 %106, 3
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 %108
%110 = load i8, i8* %109
%111 = sext i8 %110 to i32
%112 = icmp eq i32 %111, 49
br i1 %112, label %113, label %124
113: ; preds = %105
%114 = load i32, i32* %13
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 %115
%117 = call i32 @memcpy(i8* %116, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 4)
%118 = load i32, i32* %14
%119 = load i32, i32* %13
%120 = add nsw i32 %118, %119
%121 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i32 %120)
%122 = load i32, i32* %15
%123 = add nsw i32 %122, 1
store i32 %123, i32* %15
br label %124
124: ; preds = %113, %105
br label %125
125: ; preds = %124, %94
br label %126
126: ; preds = %125, %78, %70, %63
br label %127
127: ; preds = %126
%128 = load i32, i32* %13
%129 = add nsw i32 %128, 1
store i32 %129, i32* %13
br label %58
130: ; preds = %58
%131 = load i32, i32* %12
%132 = load i32, i32* %14
%133 = add nsw i32 %132, %131
store i32 %133, i32* %14
%134 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 0
%135 = load i32, i32* %12
%136 = load i32*, i32** %7
%137 = call i32 @fwrite(i8* %134, i32 1, i32 %135, i32* %136)
store i32 %137, i32* %12
br label %49
138: ; preds = %49
%139 = load i32*, i32** %7
%140 = call i32 @fclose(i32* %139)
%141 = load i32*, i32** %6
%142 = call i32 @fclose(i32* %141)
%143 = load i32, i32* %15
%144 = icmp sgt i32 %143, 0
br i1 %144, label %145, label %165
145: ; preds = %138
%146 = load i32, i32* %15
%147 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0), i32 %146)
%148 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i64 0, i64 0
%149 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%150 = call i32 @strcpy(i8* %148, i8* %149)
%151 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i64 0, i64 0
%152 = call i32 @strcat(i8* %151, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%153 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i64 0, i64 0
%154 = call i32 @remove(i8* %153)
%155 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i64 0, i64 0
%156 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.11, i64 0, i64 0), i8* %155)
%157 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%158 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i64 0, i64 0
%159 = call i32 @rename(i8* %157, i8* %158)
%160 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%161 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.12, i64 0, i64 0), i8* %160)
%162 = getelementptr inbounds [255 x i8], [255 x i8]* %9, i64 0, i64 0
%163 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%164 = call i32 @rename(i8* %162, i8* %163)
br label %169
165: ; preds = %138
%166 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.13, i64 0, i64 0))
%167 = getelementptr inbounds [255 x i8], [255 x i8]* %9, i64 0, i64 0
%168 = call i32 @remove(i8* %167)
br label %169
169: ; preds = %165, %145
%170 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i64 0, i64 0))
br label %171
171: ; preds = %169, %2
%172 = load i32, i32* @EXIT_SUCCESS
store i32 %172, i32* %3
br label %173
173: ; preds = %171, %42, %28
%174 = load i32, i32* %3
ret i32 %174
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [24 x i8] c"Gagal membuka file %s!\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [5 x i8] c".tmp\00"
@.str.3 = [3 x i8] c"wb\00"
@.str.4 = [24 x i8] c"Gagal membuat file %s!\0A\00"
@.str.5 = [5 x i8] c"PKT1\00"
@.str.6 = [33 x i8] c"Mengganti UPX0 di posisi 0x%.8x\0A\00"
@.str.7 = [5 x i8] c"PKT0\00"
@.str.8 = [33 x i8] c"Mengganti UPX1 di posisi 0x%.8x\0A\00"
@.str.9 = [29 x i8] c"%d string berhasil diganti!\0A\00"
@.str.10 = [5 x i8] c".bak\00"
@.str.11 = [29 x i8] c"Membuat file backup \22%s\22...\0A\00"
@.str.12 = [29 x i8] c"Mengganti file asli \22%s\22...\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [36 x i8] c"Hmm, tidak ada string yang diganti!\00"
@str.15 = [9 x i8] c"Selesai!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [255 x i8]
%4 = alloca [255 x i8]
%5 = alloca [255 x i8]
%6 = alloca [255 x i8]
%7 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%10 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%11 = icmp sgt i32 %0, 0
br i1 %11, label %12, label %96
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @strcpy(i8* %7, i8* %14)
%16 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %20
18: ; preds = %12
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %7)
br label %96
20: ; preds = %12
%21 = call i32 @strcpy(i8* %8, i8* %7)
%22 = call i32 @strcat(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%23 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %27
25: ; preds = %20
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %8)
br label %96
27: ; preds = %20
%28 = call i32 @rewind(i32* %16)
%29 = call i32 @feof(i32* %16)
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %77
31: ; preds = %27, %71
%32 = phi i32 [ %72, %71 ], [ 0, %27 ]
%33 = phi i32 [ %73, %71 ], [ 0, %27 ]
%34 = call i32 @fread(i8* %10, i32 1, i32 255, i32* %16)
%35 = icmp sgt i32 %34, 3
br i1 %35, label %36, label %71
36: ; preds = %31
%37 = add nsw i32 %34, -3
%38 = zext i32 %37 to i64
br label %39
39: ; preds = %36, %68
%40 = phi i64 [ 0, %36 ], [ %45, %68 ]
%41 = phi i32 [ %32, %36 ], [ %69, %68 ]
%42 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 %40
%43 = load i8, i8* %42
%44 = icmp eq i8 %43, 85
%45 = add nuw nsw i64 %40, 1
br i1 %44, label %46, label %68
46: ; preds = %39
%47 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 %45
%48 = load i8, i8* %47
%49 = icmp eq i8 %48, 80
br i1 %49, label %50, label %68
50: ; preds = %46
%51 = add nuw nsw i64 %40, 2
%52 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 %51
%53 = load i8, i8* %52
%54 = icmp eq i8 %53, 88
br i1 %54, label %55, label %68
55: ; preds = %50
%56 = add nuw nsw i64 %40, 3
%57 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 %56
%58 = load i8, i8* %57
switch i8 %58, label %68 [
i8 48, label %60
i8 49, label %59
]
59: ; preds = %55
br label %60
60: ; preds = %55, %59
%61 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), %59 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), %55 ]
%62 = phi i8* [ getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), %59 ], [ getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), %55 ]
%63 = call i32 @memcpy(i8* %42, i8* %61, i32 4)
%64 = trunc i64 %40 to i32
%65 = add nsw i32 %33, %64
%66 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %62, i32 %65)
%67 = add nsw i32 %41, 1
br label %68
68: ; preds = %60, %39, %55, %46, %50
%69 = phi i32 [ %41, %55 ], [ %41, %46 ], [ %41, %50 ], [ %41, %39 ], [ %67, %60 ]
%70 = icmp eq i64 %45, %38
br i1 %70, label %71, label %39
71: ; preds = %68, %31
%72 = phi i32 [ %32, %31 ], [ %69, %68 ]
%73 = add nsw i32 %34, %33
%74 = call i32 @fwrite(i8* %10, i32 1, i32 %34, i32* %23)
%75 = call i32 @feof(i32* %16)
%76 = icmp eq i32 %75, 0
br i1 %76, label %31, label %77
77: ; preds = %71, %27
%78 = phi i32 [ 0, %27 ], [ %72, %71 ]
%79 = call i32 @fclose(i32* %23)
%80 = call i32 @fclose(i32* %16)
%81 = icmp sgt i32 %78, 0
br i1 %81, label %82, label %91
82: ; preds = %77
%83 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0), i32 %78)
%84 = call i32 @strcpy(i8* %9, i8* %7)
%85 = call i32 @strcat(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%86 = call i32 @remove(i8* %9)
%87 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.11, i64 0, i64 0), i8* %9)
%88 = call i32 @rename(i8* %7, i8* %9)
%89 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.12, i64 0, i64 0), i8* %7)
%90 = call i32 @rename(i8* %8, i8* %7)
br label %94
91: ; preds = %77
%92 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
%93 = call i32 @remove(i8* %8)
br label %94
94: ; preds = %91, %82
%95 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.15, i64 0, i64 0))
br label %96
96: ; preds = %2, %94, %25, %18
%97 = phi i32* [ @EXIT_FAILURE, %18 ], [ @EXIT_FAILURE, %25 ], [ @EXIT_SUCCESS, %94 ], [ @EXIT_SUCCESS, %2 ]
%98 = load i32, i32* %97
ret i32 %98
}