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

/* Variables and functions */
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int system(char *);
int main(int argc, char **argv) {
  int i, aim, input, ret;
  char buff[256];
  if (argc < 5) {
    printf("Not enough args, turn to guide mode.\n");
    printf("Select aim:\n0 ioctl_privcmd_hypercall\n1 xen_pgd_pin\n2 "
           "xen_l2_entry_update\n3 remap_pfn_range\n4 xen_l3_entry_update\n5 "
           "rw_block_io\ninput:");
    scanf("%d", &input);
    memset(buff, '\0', sizeof(buff));
    sprintf(buff, "echo %d > /proc/jphyper/aim", input);
    ret = system(buff);
    if (ret) {
      printf("Can't write the arg to proc, make sure the module's .ko was "
             "insmod.\n");
      return 0;
    }
    printf("Select fault:\n");
    aim = input;
    if (aim == 0)
      printf("0 cmd\n1 mfn\n2 linear_addr\ninput:");
    if (aim == 1)
      printf("0 cmd\n1 mfn\ninput:");
    if (aim == 2)
      printf("0 ptr_address\n1 ptr\n2 val\ninput:");
    if (aim == 3)
      printf("0 pgd\n1 vm_flags\ninput:");
    if (aim == 4)
      printf("0 ptr_address\n1 ptr\n2 val\ninput:");
    if (aim == 5)
      printf("0 id\n1 nr_pages\n2 nr_segments\ninput:");
    scanf("%d", &input);
    memset(buff, '\0', sizeof(buff));
    sprintf(buff, "echo %d > /proc/jphyper/fault", input);
    ret = system(buff);
    if (ret) {
      printf("Can't write the arg to proc, make sure the module's .ko was "
             "insmod.\n");
      return 0;
    }
    printf("Select time:\n(an integer large than 0)\ninput:");
    scanf("%d", &input);
    memset(buff, '\0', sizeof(buff));
    sprintf(buff, "echo %d > /proc/jphyper/time", input);
    ret = system(buff);
    if (ret) {
      printf("Can't write the arg to proc, make sure the module's .ko was "
             "insmod.\n");
      return 0;
    }
    printf("Select id:\n(an integer)\ninput:");
    scanf("%d", &input);
    memset(buff, '\0', sizeof(buff));
    sprintf(buff, "echo %d > /proc/jphyper/id", input);
    ret = system(buff);
    if (ret) {
      printf("Can't write the arg to proc, make sure the module's .ko was "
             "insmod.\n");
      return 0;
    }
    ret = system("echo 1 > /proc/jphyper/signal");
    if (ret) {
      printf("Can't write the arg to proc, make sure the module's .ko was "
             "insmod.\n");
      return 0;
    }
    printf("FI Arg pass successfully.\n");
    return 0;
  }
  memset(buff, '\0', sizeof(buff));
  sprintf(buff, "echo %s > /proc/jphyper/aim", argv[1]);
  ret = system(buff);
  if (ret) {
    printf("Can't write the arg to proc, make sure the module's .ko was "
           "insmod.\n");
    return 0;
  }
  memset(buff, '\0', sizeof(buff));
  sprintf(buff, "echo %s > /proc/jphyper/fault", argv[2]);
  ret = system(buff);
  if (ret) {
    printf("Can't write the arg to proc, make sure the module's .ko was "
           "insmod.\n");
    return 0;
  }
  memset(buff, '\0', sizeof(buff));
  sprintf(buff, "echo %s > /proc/jphyper/time", argv[3]);
  ret = system(buff);
  if (ret) {
    printf("Can't write the arg to proc, make sure the module's .ko was "
           "insmod.\n");
    return 0;
  }
  memset(buff, '\0', sizeof(buff));
  sprintf(buff, "echo %s > /proc/jphyper/id", argv[4]);
  ret = system(buff);
  if (ret) {
    printf("Can't write the arg to proc, make sure the module's .ko was "
           "insmod.\n");
    return 0;
  }
  ret = system("echo 1 > /proc/jphyper/signal");
  if (ret) {
    printf("Can't write the arg to proc, make sure the module's .ko was "
           "insmod.\n");
    return 0;
  }
  printf("FI Arg pass successfully.\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    1432 <main+0x2e2>
lea    0xe86(%rip),%rdi
call   1040 <printf@plt>
lea    0xea0(%rip),%rdi
call   1040 <printf@plt>
lea    0xf1b(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1060 <scanf@plt>
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
lea    -0x120(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xef1(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x120(%rbp),%rdi
call   1030 <system@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     11f7 <main+0xa7>
lea    0xee6(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    15fa <main+0x4aa>
lea    0xf13(%rip),%rdi
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    121f <main+0xcf>
lea    0xf06(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x1,-0x18(%rbp)
jne    1235 <main+0xe5>
lea    0xf11(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x2,-0x18(%rbp)
jne    124b <main+0xfb>
lea    0xf0e(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x3,-0x18(%rbp)
jne    1261 <main+0x111>
lea    0xf19(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x4,-0x18(%rbp)
jne    1277 <main+0x127>
lea    0xee2(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x5,-0x18(%rbp)
jne    128d <main+0x13d>
lea    0xf05(%rip),%rdi
call   1040 <printf@plt>
lea    0xe19(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1060 <scanf@plt>
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
lea    -0x120(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xef1(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x120(%rbp),%rdi
call   1030 <system@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     12f9 <main+0x1a9>
lea    0xde4(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    15fa <main+0x4aa>
lea    0xed0(%rip),%rdi
call   1040 <printf@plt>
lea    0xda1(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1060 <scanf@plt>
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
lea    -0x120(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xec5(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x120(%rbp),%rdi
call   1030 <system@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     1371 <main+0x221>
lea    0xd6c(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    15fa <main+0x4aa>
lea    0xea3(%rip),%rdi
call   1040 <printf@plt>
lea    0xd29(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1060 <scanf@plt>
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
lea    -0x120(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xe89(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x120(%rbp),%rdi
call   1030 <system@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     13e9 <main+0x299>
lea    0xcf4(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    15fa <main+0x4aa>
lea    0xe65(%rip),%rdi
call   1030 <system@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     141a <main+0x2ca>
lea    0xcc3(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    15fa <main+0x4aa>
lea    0xe52(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    15fa <main+0x4aa>
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe33(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x120(%rbp),%rdi
call   1030 <system@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     1493 <main+0x343>
lea    0xc4a(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    15fa <main+0x4aa>
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xdee(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x120(%rbp),%rdi
call   1030 <system@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     14f4 <main+0x3a4>
lea    0xbe9(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    15fa <main+0x4aa>
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdx
lea    0xdab(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x120(%rbp),%rdi
call   1030 <system@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     1555 <main+0x405>
lea    0xb88(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    15fa <main+0x4aa>
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdx
lea    0xd67(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x120(%rbp),%rdi
call   1030 <system@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     15b6 <main+0x466>
lea    0xb27(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    15fa <main+0x4aa>
lea    0xc98(%rip),%rdi
call   1030 <system@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     15e7 <main+0x497>
lea    0xaf6(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    15fa <main+0x4aa>
lea    0xc85(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x110,%rsp
cmp    $0x4,%edi
jg     12f3 <main+0x193>
lea    0x10ef(%rip),%rdi
call   1030 <puts@plt>
lea    0xe78(%rip),%rdi
call   1050 <printf@plt>
lea    0xef3(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
mov    0xc(%rsp),%edx
lea    0xecd(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
lea    0x10e2(%rip),%r14
test   %eax,%eax
jne    13f9 <main+0x299>
lea    0x10ab(%rip),%rdi
call   1030 <puts@plt>
movslq 0xc(%rsp),%rax
cmp    $0x5,%rax
ja     1208 <main+0xa8>
lea    0x1100(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
call   1050 <printf@plt>
lea    0xe78(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
mov    0xc(%rsp),%edx
lea    0xf00(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
test   %eax,%eax
jne    13f9 <main+0x299>
lea    0xefd(%rip),%rdi
call   1050 <printf@plt>
lea    0xe22(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
mov    0xc(%rsp),%edx
lea    0xef6(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
test   %eax,%eax
jne    13f9 <main+0x299>
lea    0xef2(%rip),%rdi
call   1050 <printf@plt>
lea    0xdcc(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
mov    0xc(%rsp),%edx
lea    0xedc(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <sprintf@plt>
jmp    13cd <main+0x26d>
mov    %rsi,%r15
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
mov    0x8(%r15),%rdx
lea    0xee4(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
lea    0xf8a(%rip),%r14
test   %eax,%eax
jne    13f9 <main+0x299>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
mov    0x10(%r15),%rdx
lea    0xec0(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
test   %eax,%eax
jne    13f9 <main+0x299>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
mov    0x18(%r15),%rdx
lea    0xea5(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
test   %eax,%eax
jne    13f9 <main+0x299>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
mov    0x20(%r15),%rdx
lea    0xe8d(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
test   %eax,%eax
jne    13f9 <main+0x299>
lea    0xdfb(%rip),%rdi
call   1040 <system@plt>
test   %eax,%eax
lea    0xeb0(%rip),%rax
lea    0xec3(%rip),%r14
cmove  %rax,%r14
mov    %r14,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Not enough args, turn to guide mode.\0A\00"
@.str.1 = [135 x i8] c"Select aim:\0A0 ioctl_privcmd_hypercall\0A1 xen_pgd_pin\0A2 xen_l2_entry_update\0A3 remap_pfn_range\0A4 xen_l3_entry_update\0A5 rw_block_io\0Ainput:\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [28 x i8] c"echo %d > /proc/jphyper/aim\00"
@.str.4 = [69 x i8] c"Can't write the arg to proc, make sure the module's .ko was insmod.\0A\00"
@.str.5 = [15 x i8] c"Select fault:\0A\00"
@.str.6 = [33 x i8] c"0 cmd\0A1 mfn\0A2 linear_addr\0Ainput:\00"
@.str.7 = [19 x i8] c"0 cmd\0A1 mfn\0Ainput:\00"
@.str.8 = [33 x i8] c"0 ptr_address\0A1 ptr\0A2 val\0Ainput:\00"
@.str.9 = [24 x i8] c"0 pgd\0A1 vm_flags\0Ainput:\00"
@.str.10 = [37 x i8] c"0 id\0A1 nr_pages\0A2 nr_segments\0Ainput:\00"
@.str.11 = [30 x i8] c"echo %d > /proc/jphyper/fault\00"
@.str.12 = [46 x i8] c"Select time:\0A(an integer large than 0)\0Ainput:\00"
@.str.13 = [29 x i8] c"echo %d > /proc/jphyper/time\00"
@.str.14 = [31 x i8] c"Select id:\0A(an integer)\0Ainput:\00"
@.str.15 = [27 x i8] c"echo %d > /proc/jphyper/id\00"
@.str.16 = [30 x i8] c"echo 1 > /proc/jphyper/signal\00"
@.str.17 = [27 x i8] c"FI Arg pass successfully.\0A\00"
@.str.18 = [28 x i8] c"echo %s > /proc/jphyper/aim\00"
@.str.19 = [30 x i8] c"echo %s > /proc/jphyper/fault\00"
@.str.20 = [29 x i8] c"echo %s > /proc/jphyper/time\00"
@.str.21 = [27 x i8] c"echo %s > /proc/jphyper/id\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [256 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 5
br i1 %12, label %13, label %109
13: ; preds = %2
%14 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @printf(i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %8)
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%18 = call i32 @memset(i8* %17, i8 signext 0, i32 256)
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%20 = load i32, i32* %8
%21 = call i32 (i8*, i8*, ...) @sprintf(i8* %19, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%23 = call i32 @system(i8* %22)
store i32 %23, i32* %9
%24 = load i32, i32* %9
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %13
%27 = call i32 @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
br label %173
28: ; preds = %13
%29 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%30 = load i32, i32* %8
store i32 %30, i32* %7
%31 = load i32, i32* %7
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %28
%34 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0))
br label %35
35: ; preds = %33, %28
%36 = load i32, i32* %7
%37 = icmp eq i32 %36, 1
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
br label %40
40: ; preds = %38, %35
%41 = load i32, i32* %7
%42 = icmp eq i32 %41, 2
br i1 %42, label %43, label %45
43: ; preds = %40
%44 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0))
br label %45
45: ; preds = %43, %40
%46 = load i32, i32* %7
%47 = icmp eq i32 %46, 3
br i1 %47, label %48, label %50
48: ; preds = %45
%49 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0))
br label %50
50: ; preds = %48, %45
%51 = load i32, i32* %7
%52 = icmp eq i32 %51, 4
br i1 %52, label %53, label %55
53: ; preds = %50
%54 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0))
br label %55
55: ; preds = %53, %50
%56 = load i32, i32* %7
%57 = icmp eq i32 %56, 5
br i1 %57, label %58, label %60
58: ; preds = %55
%59 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.10, i64 0, i64 0))
br label %60
60: ; preds = %58, %55
%61 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %8)
%62 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%63 = call i32 @memset(i8* %62, i8 signext 0, i32 256)
%64 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%65 = load i32, i32* %8
%66 = call i32 (i8*, i8*, ...) @sprintf(i8* %64, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.11, i64 0, i64 0), i32 %65)
%67 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%68 = call i32 @system(i8* %67)
store i32 %68, i32* %9
%69 = load i32, i32* %9
%70 = icmp ne i32 %69, 0
br i1 %70, label %71, label %73
71: ; preds = %60
%72 = call i32 @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
br label %173
73: ; preds = %60
%74 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.12, i64 0, i64 0))
%75 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %8)
%76 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%77 = call i32 @memset(i8* %76, i8 signext 0, i32 256)
%78 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%79 = load i32, i32* %8
%80 = call i32 (i8*, i8*, ...) @sprintf(i8* %78, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.13, i64 0, i64 0), i32 %79)
%81 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%82 = call i32 @system(i8* %81)
store i32 %82, i32* %9
%83 = load i32, i32* %9
%84 = icmp ne i32 %83, 0
br i1 %84, label %85, label %87
85: ; preds = %73
%86 = call i32 @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
br label %173
87: ; preds = %73
%88 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.14, i64 0, i64 0))
%89 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %8)
%90 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%91 = call i32 @memset(i8* %90, i8 signext 0, i32 256)
%92 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%93 = load i32, i32* %8
%94 = call i32 (i8*, i8*, ...) @sprintf(i8* %92, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.15, i64 0, i64 0), i32 %93)
%95 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%96 = call i32 @system(i8* %95)
store i32 %96, i32* %9
%97 = load i32, i32* %9
%98 = icmp ne i32 %97, 0
br i1 %98, label %99, label %101
99: ; preds = %87
%100 = call i32 @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
br label %173
101: ; preds = %87
%102 = call i32 @system(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.16, i64 0, i64 0))
store i32 %102, i32* %9
%103 = load i32, i32* %9
%104 = icmp ne i32 %103, 0
br i1 %104, label %105, label %107
105: ; preds = %101
%106 = call i32 @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
br label %173
107: ; preds = %101
%108 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.17, i64 0, i64 0))
store i32 0, i32* %3
br label %173
109: ; preds = %2
%110 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%111 = call i32 @memset(i8* %110, i8 signext 0, i32 256)
%112 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%113 = load i8**, i8*** %5
%114 = getelementptr inbounds i8*, i8** %113, i64 1
%115 = load i8*, i8** %114
%116 = call i32 (i8*, i8*, ...) @sprintf(i8* %112, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.18, i64 0, i64 0), i8* %115)
%117 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%118 = call i32 @system(i8* %117)
store i32 %118, i32* %9
%119 = load i32, i32* %9
%120 = icmp ne i32 %119, 0
br i1 %120, label %121, label %123
121: ; preds = %109
%122 = call i32 @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
br label %173
123: ; preds = %109
%124 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%125 = call i32 @memset(i8* %124, i8 signext 0, i32 256)
%126 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%127 = load i8**, i8*** %5
%128 = getelementptr inbounds i8*, i8** %127, i64 2
%129 = load i8*, i8** %128
%130 = call i32 (i8*, i8*, ...) @sprintf(i8* %126, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.19, i64 0, i64 0), i8* %129)
%131 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%132 = call i32 @system(i8* %131)
store i32 %132, i32* %9
%133 = load i32, i32* %9
%134 = icmp ne i32 %133, 0
br i1 %134, label %135, label %137
135: ; preds = %123
%136 = call i32 @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
br label %173
137: ; preds = %123
%138 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%139 = call i32 @memset(i8* %138, i8 signext 0, i32 256)
%140 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%141 = load i8**, i8*** %5
%142 = getelementptr inbounds i8*, i8** %141, i64 3
%143 = load i8*, i8** %142
%144 = call i32 (i8*, i8*, ...) @sprintf(i8* %140, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.20, i64 0, i64 0), i8* %143)
%145 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%146 = call i32 @system(i8* %145)
store i32 %146, i32* %9
%147 = load i32, i32* %9
%148 = icmp ne i32 %147, 0
br i1 %148, label %149, label %151
149: ; preds = %137
%150 = call i32 @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
br label %173
151: ; preds = %137
%152 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%153 = call i32 @memset(i8* %152, i8 signext 0, i32 256)
%154 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%155 = load i8**, i8*** %5
%156 = getelementptr inbounds i8*, i8** %155, i64 4
%157 = load i8*, i8** %156
%158 = call i32 (i8*, i8*, ...) @sprintf(i8* %154, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.21, i64 0, i64 0), i8* %157)
%159 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%160 = call i32 @system(i8* %159)
store i32 %160, i32* %9
%161 = load i32, i32* %9
%162 = icmp ne i32 %161, 0
br i1 %162, label %163, label %165
163: ; preds = %151
%164 = call i32 @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
br label %173
165: ; preds = %151
%166 = call i32 @system(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.16, i64 0, i64 0))
store i32 %166, i32* %9
%167 = load i32, i32* %9
%168 = icmp ne i32 %167, 0
br i1 %168, label %169, label %171
169: ; preds = %165
%170 = call i32 @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
br label %173
171: ; preds = %165
%172 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.17, i64 0, i64 0))
store i32 0, i32* %3
br label %173
173: ; preds = %171, %169, %163, %149, %135, %121, %107, %105, %99, %85, %71, %26
%174 = load i32, i32* %3
ret i32 %174
}

LLVM IR (-O2):
@.str.1 = [135 x i8] c"Select aim:\0A0 ioctl_privcmd_hypercall\0A1 xen_pgd_pin\0A2 xen_l2_entry_update\0A3 remap_pfn_range\0A4 xen_l3_entry_update\0A5 rw_block_io\0Ainput:\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [28 x i8] c"echo %d > /proc/jphyper/aim\00"
@.str.6 = [33 x i8] c"0 cmd\0A1 mfn\0A2 linear_addr\0Ainput:\00"
@.str.7 = [19 x i8] c"0 cmd\0A1 mfn\0Ainput:\00"
@.str.8 = [33 x i8] c"0 ptr_address\0A1 ptr\0A2 val\0Ainput:\00"
@.str.9 = [24 x i8] c"0 pgd\0A1 vm_flags\0Ainput:\00"
@.str.10 = [37 x i8] c"0 id\0A1 nr_pages\0A2 nr_segments\0Ainput:\00"
@.str.11 = [30 x i8] c"echo %d > /proc/jphyper/fault\00"
@.str.12 = [46 x i8] c"Select time:\0A(an integer large than 0)\0Ainput:\00"
@.str.13 = [29 x i8] c"echo %d > /proc/jphyper/time\00"
@.str.14 = [31 x i8] c"Select id:\0A(an integer)\0Ainput:\00"
@.str.15 = [27 x i8] c"echo %d > /proc/jphyper/id\00"
@.str.16 = [30 x i8] c"echo 1 > /proc/jphyper/signal\00"
@.str.18 = [28 x i8] c"echo %s > /proc/jphyper/aim\00"
@.str.19 = [30 x i8] c"echo %s > /proc/jphyper/fault\00"
@.str.20 = [29 x i8] c"echo %s > /proc/jphyper/time\00"
@.str.21 = [27 x i8] c"echo %s > /proc/jphyper/id\00"
@str.27 = [37 x i8] c"Not enough args, turn to guide mode.\00"
@str.28 = [14 x i8] c"Select fault:\00"
@str.29 = [26 x i8] c"FI Arg pass successfully.\00"
@str.34 = [68 x i8] c"Can't write the arg to proc, make sure the module's .ko was insmod.\00"
@reltable.main = [6 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([33 x i8]* @.str.6 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.7 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([33 x i8]* @.str.8 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([24 x i8]* @.str.9 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([33 x i8]* @.str.8 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([37 x i8]* @.str.10 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32)]
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [256 x i8]
%5 = bitcast i32* %3 to i8*
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%7 = icmp slt i32 %0, 5
br i1 %7, label %8, label %53
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.27, i64 0, i64 0))
%10 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([135 x i8], [135 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%12 = call i32 @memset(i8* %6, i8 signext 0, i32 256)
%13 = load i32, i32* %3
%14 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %13)
%15 = call i32 @system(i8* %6)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %85
17: ; preds = %8
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.28, i64 0, i64 0))
%19 = load i32, i32* %3
%20 = icmp ult i32 %19, 6
br i1 %20, label %21, label %26
21: ; preds = %17
%22 = sext i32 %19 to i64
%23 = shl i64 %22, 2
%24 = call i8* @llvm.load.relative.i64(i8* bitcast ([6 x i32]* @reltable.main to i8*), i64 %23)
%25 = call i32 @printf(i8* dereferenceable(1) %24)
br label %26
26: ; preds = %17, %21
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%28 = call i32 @memset(i8* %6, i8 signext 0, i32 256)
%29 = load i32, i32* %3
%30 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.11, i64 0, i64 0), i32 %29)
%31 = call i32 @system(i8* %6)
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %85
33: ; preds = %26
%34 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.12, i64 0, i64 0))
%35 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%36 = call i32 @memset(i8* %6, i8 signext 0, i32 256)
%37 = load i32, i32* %3
%38 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.13, i64 0, i64 0), i32 %37)
%39 = call i32 @system(i8* %6)
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %85
41: ; preds = %33
%42 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.14, i64 0, i64 0))
%43 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%44 = call i32 @memset(i8* %6, i8 signext 0, i32 256)
%45 = load i32, i32* %3
%46 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.15, i64 0, i64 0), i32 %45)
%47 = call i32 @system(i8* %6)
%48 = icmp eq i32 %47, 0
br i1 %48, label %49, label %85
49: ; preds = %41
%50 = call i32 @system(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.16, i64 0, i64 0))
%51 = icmp eq i32 %50, 0
%52 = select i1 %51, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @str.29, i64 0, i64 0), i8* getelementptr inbounds ([68 x i8], [68 x i8]* @str.34, i64 0, i64 0)
br label %85
53: ; preds = %2
%54 = call i32 @memset(i8* %6, i8 signext 0, i32 256)
%55 = getelementptr inbounds i8*, i8** %1, i64 1
%56 = load i8*, i8** %55
%57 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.18, i64 0, i64 0), i8* %56)
%58 = call i32 @system(i8* %6)
%59 = icmp eq i32 %58, 0
br i1 %59, label %60, label %85
60: ; preds = %53
%61 = call i32 @memset(i8* %6, i8 signext 0, i32 256)
%62 = getelementptr inbounds i8*, i8** %1, i64 2
%63 = load i8*, i8** %62
%64 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.19, i64 0, i64 0), i8* %63)
%65 = call i32 @system(i8* %6)
%66 = icmp eq i32 %65, 0
br i1 %66, label %67, label %85
67: ; preds = %60
%68 = call i32 @memset(i8* %6, i8 signext 0, i32 256)
%69 = getelementptr inbounds i8*, i8** %1, i64 3
%70 = load i8*, i8** %69
%71 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.20, i64 0, i64 0), i8* %70)
%72 = call i32 @system(i8* %6)
%73 = icmp eq i32 %72, 0
br i1 %73, label %74, label %85
74: ; preds = %67
%75 = call i32 @memset(i8* %6, i8 signext 0, i32 256)
%76 = getelementptr inbounds i8*, i8** %1, i64 4
%77 = load i8*, i8** %76
%78 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.21, i64 0, i64 0), i8* %77)
%79 = call i32 @system(i8* %6)
%80 = icmp eq i32 %79, 0
br i1 %80, label %81, label %85
81: ; preds = %74
%82 = call i32 @system(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.16, i64 0, i64 0))
%83 = icmp eq i32 %82, 0
%84 = select i1 %83, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @str.29, i64 0, i64 0), i8* getelementptr inbounds ([68 x i8], [68 x i8]* @str.34, i64 0, i64 0)
br label %85
85: ; preds = %81, %74, %67, %60, %53, %49, %41, %33, %26, %8
%86 = phi i8* [ getelementptr inbounds ([68 x i8], [68 x i8]* @str.34, i64 0, i64 0), %8 ], [ getelementptr inbounds ([68 x i8], [68 x i8]* @str.34, i64 0, i64 0), %26 ], [ getelementptr inbounds ([68 x i8], [68 x i8]* @str.34, i64 0, i64 0), %33 ], [ getelementptr inbounds ([68 x i8], [68 x i8]* @str.34, i64 0, i64 0), %41 ], [ %52, %49 ], [ getelementptr inbounds ([68 x i8], [68 x i8]* @str.34, i64 0, i64 0), %53 ], [ getelementptr inbounds ([68 x i8], [68 x i8]* @str.34, i64 0, i64 0), %60 ], [ getelementptr inbounds ([68 x i8], [68 x i8]* @str.34, i64 0, i64 0), %67 ], [ getelementptr inbounds ([68 x i8], [68 x i8]* @str.34, i64 0, i64 0), %74 ], [ %84, %81 ]
%87 = call i32 @puts(i8* dereferenceable(1) %86)
ret i32 0
}