#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*/ O_RDWR;
int /*<<< orphan*/ VT_ACTIVATE;
int /*<<< orphan*/ VT_LOCKSWITCH;
int /*<<< orphan*/ VT_UNLOCKSWITCH;
int atoi(char *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int ioctl(int, int /*<<< orphan*/, ...);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
int main(int argc, char **argv) {
  int consfd = -1;
  int vtn = 0;
  int sleeptime = 0;
  FILE *consio;
  char vtname[100];
  if (argc == 1) {
    printf("I want a vt number\n");
    return 1;
  }
  vtn = atoi(argv[1]);
  if (vtn == 0) {
    printf("I want a numeric vt number\n");
    return 1;
  }
  snprintf(vtname, 20, "/dev/tty%d", vtn);
  printf("VT name is %s\n", vtname);
  consio = fopen(vtname, "r+");
  if (consio == NULL) {
    printf("Oops, cannot open the vt\n");
    return 2;
  }
  consfd = open("/dev/console", O_RDWR);
  if (consfd == -1) {
    printf("Oops, cannot open /dev/console");
    return 2;
  }
  printf("Starting\n");
  ioctl(consfd, VT_UNLOCKSWITCH);
  if (ioctl(consfd, VT_ACTIVATE, vtn) == -1) {
    printf("Couldn't switch console\n");
    return 3;
  }
  fprintf(consio, "Starting\n");
  if (ioctl(consfd, VT_LOCKSWITCH) == -1) {
    printf("Couldn't lock console\n");
    fprintf(consio, "Couldn't lock console\n");
    return 3;
  }
  printf("Mwahaha?\n");
  fprintf(consio, "Mwahaha?\n");
  if (argc > 2) {
    sleeptime = atoi(argv[2]);
  }
  if (sleeptime == 0) {
    sleeptime = 5;
  };
  sleep(sleeptime);
  printf("Finishing\n");
  fprintf(consio, "Finishing\n");
  if (ioctl(consfd, VT_UNLOCKSWITCH) == -1) {
    printf("Couldn't unlock console, strange\n");
    fprintf(consio, "Couldn't unlock console, strange\n");
    return 4;
  }
  printf("Bye\n");
  fprintf(consio, "Bye\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    11d2 <main+0x52>
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1438 <main+0x2b8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    1206 <main+0x86>
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1438 <main+0x2b8>
lea    -0x90(%rbp),%rdi
mov    -0x18(%rbp),%ecx
mov    $0x14,%esi
lea    0xe14(%rip),%rdx
call   1040 <snprintf@plt>
lea    -0x90(%rbp),%rsi
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x90(%rbp),%rdi
lea    0xe06(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1272 <main+0xf2>
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1438 <main+0x2b8>
mov    0x2d6f(%rip),%rax
mov    (%rax),%esi
lea    0xdf7(%rip),%rdi
call   1070 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    12ae <main+0x12e>
lea    0xdcc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1438 <main+0x2b8>
lea    0xdd1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
mov    0x2d0a(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1050 <ioctl@plt>
mov    -0x14(%rbp),%edi
mov    0x2d07(%rip),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%edx
mov    $0x0,%al
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
jne    1308 <main+0x188>
lea    0xd9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x3,-0x4(%rbp)
jmp    1438 <main+0x2b8>
mov    -0x28(%rbp),%rdi
lea    0xd73(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x14(%rbp),%edi
mov    0x2cb6(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
jne    135e <main+0x1de>
lea    0xd6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rdi
lea    0xd5c(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x3,-0x4(%rbp)
jmp    1438 <main+0x2b8>
lea    0xd5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rdi
lea    0xd49(%rip),%rsi
call   1060 <fprintf@plt>
cmpl   $0x2,-0x8(%rbp)
jle    1396 <main+0x216>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    13a7 <main+0x227>
movl   $0x5,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   10a0 <sleep@plt>
lea    0xd14(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rdi
lea    0xd02(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x14(%rbp),%edi
mov    0x2bf9(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
jne    1413 <main+0x293>
lea    0xce5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rdi
lea    0xcd3(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x4,-0x4(%rbp)
jmp    1438 <main+0x2b8>
lea    0xcdd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rdi
lea    0xccb(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
cmp    $0x1,%edi
jne    11af <main+0x1f>
lea    0xf92(%rip),%rdi
jmp    1351 <main+0x1c1>
mov    %rsi,%r12
mov    %edi,%r13d
mov    0x8(%rsi),%rdi
call   1090 <atoi@plt>
test   %eax,%eax
je     134a <main+0x1ba>
mov    %eax,%ebx
lea    0xe31(%rip),%rdx
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    $0x14,%esi
mov    %eax,%ecx
call   1050 <snprintf@plt>
lea    0xe23(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe21(%rip),%rsi
mov    %rbp,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     136c <main+0x1dc>
mov    %rax,%r14
mov    0x2dd4(%rip),%rax
mov    (%rax),%esi
lea    0xe12(%rip),%rdi
call   1070 <open@plt>
cmp    $0xffffffff,%eax
je     137f <main+0x1ef>
mov    %eax,%r15d
lea    0xe64(%rip),%rdi
call   1030 <puts@plt>
mov    0x2d8f(%rip),%rbp
mov    0x0(%rbp),%esi
mov    %r15d,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
mov    0x2d8b(%rip),%rax
mov    (%rax),%esi
mov    %r15d,%edi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <ioctl@plt>
cmp    $0xffffffff,%eax
je     1394 <main+0x204>
lea    0xdc9(%rip),%rdi
mov    $0x9,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10a0 <fwrite@plt>
mov    0x2d4c(%rip),%rax
mov    (%rax),%esi
mov    %r15d,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
cmp    $0xffffffff,%eax
je     13a7 <main+0x217>
lea    0xdfa(%rip),%rdi
call   1030 <puts@plt>
lea    0xda9(%rip),%rdi
mov    $0x9,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10a0 <fwrite@plt>
cmp    $0x3,%r13d
jl     12dc <main+0x14c>
mov    0x10(%r12),%rdi
call   1090 <atoi@plt>
mov    %eax,%edi
test   %eax,%eax
jne    12e1 <main+0x151>
mov    $0x5,%edi
call   10b0 <sleep@plt>
lea    0xdbe(%rip),%rdi
call   1030 <puts@plt>
lea    0xd6e(%rip),%rdi
mov    $0xa,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10a0 <fwrite@plt>
mov    0x0(%rbp),%esi
xor    %ebx,%ebx
mov    %r15d,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
cmp    $0xffffffff,%eax
je     13d3 <main+0x243>
lea    0xd8b(%rip),%rdi
call   1030 <puts@plt>
lea    0xd5e(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10a0 <fwrite@plt>
jmp    135b <main+0x1cb>
lea    0xdd0(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd95(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%ebx
jmp    135b <main+0x1cb>
lea    0xc97(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x2,%ebx
jmp    135b <main+0x1cb>
lea    0xd55(%rip),%rdi
call   1030 <puts@plt>
mov    $0x3,%ebx
jmp    135b <main+0x1cb>
lea    0xd2c(%rip),%rdi
call   1030 <puts@plt>
lea    0xc8c(%rip),%rdi
mov    $0x16,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10a0 <fwrite@plt>
mov    $0x3,%ebx
jmp    135b <main+0x1cb>
lea    0xcdf(%rip),%rdi
call   1030 <puts@plt>
lea    0xc8c(%rip),%rdi
mov    $0x21,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10a0 <fwrite@plt>
mov    $0x4,%ebx
jmp    135b <main+0x1cb>

LLVM IR (-O0):
@.str = [20 x i8] c"I want a vt number\0A\00"
@.str.1 = [28 x i8] c"I want a numeric vt number\0A\00"
@.str.2 = [11 x i8] c"/dev/tty%d\00"
@.str.3 = [15 x i8] c"VT name is %s\0A\00"
@.str.4 = [3 x i8] c"r+\00"
@.str.5 = [26 x i8] c"Oops, cannot open the vt\0A\00"
@.str.6 = [13 x i8] c"/dev/console\00"
@O_RDWR = global i32 0
@.str.7 = [31 x i8] c"Oops, cannot open /dev/console\00"
@.str.8 = [10 x i8] c"Starting\0A\00"
@VT_UNLOCKSWITCH = global i32 0
@VT_ACTIVATE = global i32 0
@.str.9 = [25 x i8] c"Couldn't switch console\0A\00"
@VT_LOCKSWITCH = global i32 0
@.str.10 = [23 x i8] c"Couldn't lock console\0A\00"
@.str.11 = [10 x i8] c"Mwahaha?\0A\00"
@.str.12 = [11 x i8] c"Finishing\0A\00"
@.str.13 = [34 x i8] c"Couldn't unlock console, strange\0A\00"
@.str.14 = [5 x i8] c"Bye\0A\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 [100 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 -1, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %99
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @atoi(i8* %18)
store i32 %19, i32* %7
%20 = load i32, i32* %7
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %15
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %99
24: ; preds = %15
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%26 = load i32, i32* %7
%27 = call i32 @snprintf(i8* %25, i32 20, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %26)
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* %28)
%30 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%31 = call i32* @fopen(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %31, i32** %9
%32 = load i32*, i32** %9
%33 = icmp eq i32* %32, null
br i1 %33, label %34, label %36
34: ; preds = %24
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
store i32 2, i32* %3
br label %99
36: ; preds = %24
%37 = load i32, i32* @O_RDWR
%38 = call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 %37)
store i32 %38, i32* %6
%39 = load i32, i32* %6
%40 = icmp eq i32 %39, -1
br i1 %40, label %41, label %43
41: ; preds = %36
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0))
store i32 2, i32* %3
br label %99
43: ; preds = %36
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
%45 = load i32, i32* %6
%46 = load i32, i32* @VT_UNLOCKSWITCH
%47 = call i32 (i32, i32, ...) @ioctl(i32 %45, i32 %46)
%48 = load i32, i32* %6
%49 = load i32, i32* @VT_ACTIVATE
%50 = load i32, i32* %7
%51 = call i32 (i32, i32, ...) @ioctl(i32 %48, i32 %49, i32 %50)
%52 = icmp eq i32 %51, -1
br i1 %52, label %53, label %55
53: ; preds = %43
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0))
store i32 3, i32* %3
br label %99
55: ; preds = %43
%56 = load i32*, i32** %9
%57 = call i32 @fprintf(i32* %56, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
%58 = load i32, i32* %6
%59 = load i32, i32* @VT_LOCKSWITCH
%60 = call i32 (i32, i32, ...) @ioctl(i32 %58, i32 %59)
%61 = icmp eq i32 %60, -1
br i1 %61, label %62, label %66
62: ; preds = %55
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0))
%64 = load i32*, i32** %9
%65 = call i32 @fprintf(i32* %64, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0))
store i32 3, i32* %3
br label %99
66: ; preds = %55
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0))
%68 = load i32*, i32** %9
%69 = call i32 @fprintf(i32* %68, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0))
%70 = load i32, i32* %4
%71 = icmp sgt i32 %70, 2
br i1 %71, label %72, label %77
72: ; preds = %66
%73 = load i8**, i8*** %5
%74 = getelementptr inbounds i8*, i8** %73, i64 2
%75 = load i8*, i8** %74
%76 = call i32 @atoi(i8* %75)
store i32 %76, i32* %8
br label %77
77: ; preds = %72, %66
%78 = load i32, i32* %8
%79 = icmp eq i32 %78, 0
br i1 %79, label %80, label %81
80: ; preds = %77
store i32 5, i32* %8
br label %81
81: ; preds = %80, %77
%82 = load i32, i32* %8
%83 = call i32 @sleep(i32 %82)
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.12, i64 0, i64 0))
%85 = load i32*, i32** %9
%86 = call i32 @fprintf(i32* %85, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.12, i64 0, i64 0))
%87 = load i32, i32* %6
%88 = load i32, i32* @VT_UNLOCKSWITCH
%89 = call i32 (i32, i32, ...) @ioctl(i32 %87, i32 %88)
%90 = icmp eq i32 %89, -1
br i1 %90, label %91, label %95
91: ; preds = %81
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.13, i64 0, i64 0))
%93 = load i32*, i32** %9
%94 = call i32 @fprintf(i32* %93, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.13, i64 0, i64 0))
store i32 4, i32* %3
br label %99
95: ; preds = %81
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0))
%97 = load i32*, i32** %9
%98 = call i32 @fprintf(i32* %97, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0))
store i32 0, i32* %3
br label %99
99: ; preds = %95, %91, %62, %53, %41, %34, %22, %13
%100 = load i32, i32* %3
ret i32 %100
}

LLVM IR (-O2):
@.str.2 = [11 x i8] c"/dev/tty%d\00"
@.str.3 = [15 x i8] c"VT name is %s\0A\00"
@.str.4 = [3 x i8] c"r+\00"
@.str.6 = [13 x i8] c"/dev/console\00"
@O_RDWR = global i32 0
@.str.7 = [31 x i8] c"Oops, cannot open /dev/console\00"
@.str.8 = [10 x i8] c"Starting\0A\00"
@VT_UNLOCKSWITCH = global i32 0
@VT_ACTIVATE = global i32 0
@VT_LOCKSWITCH = global i32 0
@.str.10 = [23 x i8] c"Couldn't lock console\0A\00"
@.str.11 = [10 x i8] c"Mwahaha?\0A\00"
@.str.12 = [11 x i8] c"Finishing\0A\00"
@.str.13 = [34 x i8] c"Couldn't unlock console, strange\0A\00"
@.str.14 = [5 x i8] c"Bye\0A\00"
@str = [9 x i8] c"Starting\00"
@str.15 = [9 x i8] c"Mwahaha?\00"
@str.16 = [10 x i8] c"Finishing\00"
@str.17 = [4 x i8] c"Bye\00"
@str.18 = [33 x i8] c"Couldn't unlock console, strange\00"
@str.19 = [22 x i8] c"Couldn't lock console\00"
@str.20 = [24 x i8] c"Couldn't switch console\00"
@str.21 = [25 x i8] c"Oops, cannot open the vt\00"
@str.22 = [27 x i8] c"I want a numeric vt number\00"
@str.23 = [19 x i8] c"I want a vt number\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 1
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.23, i64 0, i64 0))
br label %69
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.22, i64 0, i64 0))
br label %69
15: ; preds = %8
%16 = call i32 @snprintf(i8* %4, i32 20, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%18 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %22
20: ; preds = %15
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.21, i64 0, i64 0))
br label %69
22: ; preds = %15
%23 = load i32, i32* @O_RDWR
%24 = call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 %23)
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0))
br label %69
28: ; preds = %22
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%30 = load i32, i32* @VT_UNLOCKSWITCH
%31 = call i32 (i32, i32, ...) @ioctl(i32 %24, i32 %30)
%32 = load i32, i32* @VT_ACTIVATE
%33 = call i32 (i32, i32, ...) @ioctl(i32 %24, i32 %32, i32 %11)
%34 = icmp eq i32 %33, -1
br i1 %34, label %35, label %37
35: ; preds = %28
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.20, i64 0, i64 0))
br label %69
37: ; preds = %28
%38 = call i64 @fwrite(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i64 9, i64 1, i32* %18)
%39 = load i32, i32* @VT_LOCKSWITCH
%40 = call i32 (i32, i32, ...) @ioctl(i32 %24, i32 %39)
%41 = icmp eq i32 %40, -1
br i1 %41, label %42, label %45
42: ; preds = %37
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.19, i64 0, i64 0))
%44 = call i64 @fwrite(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0), i64 22, i64 1, i32* %18)
br label %69
45: ; preds = %37
%46 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.15, i64 0, i64 0))
%47 = call i64 @fwrite(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i64 9, i64 1, i32* %18)
%48 = icmp sgt i32 %0, 2
br i1 %48, label %49, label %54
49: ; preds = %45
%50 = getelementptr inbounds i8*, i8** %1, i64 2
%51 = load i8*, i8** %50
%52 = call i32 @atoi(i8* %51)
%53 = icmp eq i32 %52, 0
br i1 %53, label %54, label %55
54: ; preds = %45, %49
br label %55
55: ; preds = %49, %54
%56 = phi i32 [ 5, %54 ], [ %52, %49 ]
%57 = call i32 @sleep(i32 %56)
%58 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.16, i64 0, i64 0))
%59 = call i64 @fwrite(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.12, i64 0, i64 0), i64 10, i64 1, i32* %18)
%60 = load i32, i32* @VT_UNLOCKSWITCH
%61 = call i32 (i32, i32, ...) @ioctl(i32 %24, i32 %60)
%62 = icmp eq i32 %61, -1
br i1 %62, label %63, label %66
63: ; preds = %55
%64 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.18, i64 0, i64 0))
%65 = call i64 @fwrite(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.13, i64 0, i64 0), i64 33, i64 1, i32* %18)
br label %69
66: ; preds = %55
%67 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.17, i64 0, i64 0))
%68 = call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0), i64 4, i64 1, i32* %18)
br label %69
69: ; preds = %66, %63, %42, %35, %26, %20, %13, %6
%70 = phi i32 [ 1, %6 ], [ 1, %13 ], [ 2, %20 ], [ 2, %26 ], [ 3, %35 ], [ 3, %42 ], [ 4, %63 ], [ 0, %66 ]
ret i32 %70
}