#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*/ timebuf;
typedef int /*<<< orphan*/ mybuf;
typedef int /*<<< orphan*/ cpubuf;

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int atoi(char *);
int /*<<< orphan*/ displayExtendedStats();
int /*<<< orphan*/ exit(int);
int getopt(int, char **, char *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int /*<<< orphan*/ sscanf(char *, char *, char *, ...);
main(int argc, char **argv) {
  char mybuf[512];
  char timebuf[20];
  char uptime[20];
  char uptime1[20];
  char disk[12];
  char disk1[12];
  char disk2[12];
  char disk3[12];
  char disk4[12];
  char disk5[12];
  char numcpu[3];
  char vernum[80];
  char vernum1[80];
  char cpu[12];
  char cpu1[12];
  char cpu2[12];
  char cpu3[12];
  char cpu4[12];
  char cpu5[12];
  int fd;
  int cpus;
  int s;
  int seconds;
  int minutes;
  int hours;
  int days;
  int weeks;
  int fd_cpu;
  char cpubuf[512];
  int fd_boot;
  int errs;
  int count;
  int i;
  long int u1, u2;
  printf("Welcome to Tom Pretto's Hardware Status Program (mystats)!\n");
  if ((fd_cpu = open("/proc/cpuinfo", O_RDONLY)) < 0) {
    perror("Bad open");
    exit(-1);
  }
  if ((count = read(fd_cpu, &cpubuf[0], sizeof(cpubuf))) > 0) {
    for (i = 0; i < 70; i++) {
      sscanf(&cpubuf[i], "processor	:%s", &numcpu[0]);
      sscanf(&cpubuf[i], "model name	:%s %s %s %s %s", &cpu[0], &cpu1[0],
             &cpu2[0], &cpu3[0], &cpu4[0]);
    }
    printf("cpu:	%s %s %s %s %s\n", &cpu[0], &cpu1[0], &cpu2[0],
           &cpu3[0], &cpu4[0]);
    cpus = atoi(&numcpu[0]);
    printf("Number of processors:  [%d]\n", ++cpus);
  }
  if (count < 0) {
    perror("Bad read");
    exit(-1);
  }
  if ((fd = open("/proc/version", O_RDONLY)) < 0) {
    perror("Bad open");
    exit(-1);
  }
  while ((count = read(fd, &mybuf[0], sizeof(mybuf))) > 0) {
    sscanf(&mybuf[0], "Linux version  %s", &vernum[0]);
  }
  if (count < 0) {
    perror("Bad read");
    exit(-1);
  } else
    (printf("Kernel version:  %s\n", &vernum[0]));
  if ((fd_boot = open("/proc/uptime", O_RDONLY)) < 0) {
    perror("Bad open");
    exit(-1);
  }
  if (count < 0) {
    perror("Bad read");
    exit(-1);
  }
  if ((count = read(fd_boot, &timebuf[0], sizeof(timebuf))) > 0) {
    sscanf(&timebuf[0], "%s %s", &uptime[0], &uptime1[0]);
  }
  seconds = atoi(&uptime[0]);
  days = seconds / 86400;
  hours = ((seconds % 86400) / 3600);
  minutes = ((seconds % 3600) / 60);
  seconds = (seconds % 60);
  printf("System up for %d:%.2d:%.2d:%.2d\n", days, hours, minutes, seconds);
  if (argc == 2) {
    if ((s = getopt(argc, argv, "s")) != -1) {
      switch (s) {
      case 's':
        displayExtendedStats();
        break;
      default:
        break;
      }
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x600,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e2a(%rip),%rax
mov    (%rax),%esi
lea    0xe75(%rip),%rdi
call   1060 <open@plt>
mov    %eax,-0x3cc(%rbp)
cmp    $0x0,%eax
jge    11f1 <main+0x61>
lea    0xe68(%rip),%rdi
call   1070 <perror@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
mov    -0x3cc(%rbp),%edi
lea    -0x5d0(%rbp),%rsi
mov    $0x200,%edx
call   1040 <read@plt>
mov    %eax,-0x5dc(%rbp)
cmp    $0x0,%eax
jle    130e <main+0x17e>
movl   $0x0,-0x5e0(%rbp)
cmpl   $0x46,-0x5e0(%rbp)
jge    12ae <main+0x11e>
movslq -0x5e0(%rbp),%rax
lea    -0x5d0(%rbp),%rdi
add    %rax,%rdi
lea    -0x2bb(%rbp),%rdx
lea    0xe06(%rip),%rsi
mov    $0x0,%al
call   1050 <sscanf@plt>
movslq -0x5e0(%rbp),%rax
lea    -0x5d0(%rbp),%rdi
add    %rax,%rdi
lea    -0x36c(%rbp),%rdx
lea    -0x378(%rbp),%rcx
lea    -0x384(%rbp),%r8
lea    -0x390(%rbp),%r9
lea    -0x39c(%rbp),%rax
lea    0xdd2(%rip),%rsi
mov    %rax,(%rsp)
mov    $0x0,%al
call   1050 <sscanf@plt>
mov    -0x5e0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5e0(%rbp)
jmp    1221 <main+0x91>
lea    -0x36c(%rbp),%rsi
lea    -0x378(%rbp),%rdx
lea    -0x384(%rbp),%rcx
lea    -0x390(%rbp),%r8
lea    -0x39c(%rbp),%r9
lea    0xda4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x2bb(%rbp),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x3b0(%rbp)
mov    -0x3b0(%rbp),%esi
add    $0x1,%esi
mov    %esi,-0x3b0(%rbp)
lea    0xd8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x5dc(%rbp)
jge    1331 <main+0x1a1>
lea    0xd8c(%rip),%rdi
call   1070 <perror@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
mov    0x2cb0(%rip),%rax
mov    (%rax),%esi
lea    0xd76(%rip),%rdi
call   1060 <open@plt>
mov    %eax,-0x3ac(%rbp)
cmp    $0x0,%eax
jge    136b <main+0x1db>
lea    0xcee(%rip),%rdi
call   1070 <perror@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
jmp    1370 <main+0x1e0>
mov    -0x3ac(%rbp),%edi
lea    -0x210(%rbp),%rsi
mov    $0x200,%edx
call   1040 <read@plt>
mov    %eax,-0x5dc(%rbp)
cmp    $0x0,%eax
jle    13b7 <main+0x227>
lea    -0x210(%rbp),%rdi
lea    -0x310(%rbp),%rdx
lea    0xd1a(%rip),%rsi
mov    $0x0,%al
call   1050 <sscanf@plt>
jmp    1370 <main+0x1e0>
cmpl   $0x0,-0x5dc(%rbp)
jge    13da <main+0x24a>
lea    0xce3(%rip),%rdi
call   1070 <perror@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
lea    -0x310(%rbp),%rsi
lea    0xcef(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2bf2(%rip),%rax
mov    (%rax),%esi
lea    0xced(%rip),%rdi
call   1060 <open@plt>
mov    %eax,-0x5d4(%rbp)
cmp    $0x0,%eax
jge    1429 <main+0x299>
lea    0xc30(%rip),%rdi
call   1070 <perror@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
cmpl   $0x0,-0x5dc(%rbp)
jge    144c <main+0x2bc>
lea    0xc71(%rip),%rdi
call   1070 <perror@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
mov    -0x5d4(%rbp),%edi
lea    -0x230(%rbp),%rsi
mov    $0x14,%edx
call   1040 <read@plt>
mov    %eax,-0x5dc(%rbp)
cmp    $0x0,%eax
jle    1495 <main+0x305>
lea    -0x230(%rbp),%rdi
lea    -0x250(%rbp),%rdx
lea    -0x270(%rbp),%rcx
lea    0xbe8(%rip),%rsi
mov    $0x0,%al
call   1050 <sscanf@plt>
lea    -0x250(%rbp),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x3b8(%rbp)
mov    -0x3b8(%rbp),%eax
mov    $0x15180,%ecx
cltd
idiv   %ecx
mov    %eax,-0x3c4(%rbp)
mov    -0x3b8(%rbp),%eax
mov    $0x15180,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %eax,-0x3c0(%rbp)
mov    -0x3b8(%rbp),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,-0x3bc(%rbp)
mov    -0x3b8(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x3b8(%rbp)
mov    -0x3c4(%rbp),%esi
mov    -0x3c0(%rbp),%edx
mov    -0x3bc(%rbp),%ecx
mov    -0x3b8(%rbp),%r8d
lea    0xbce(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x2,-0x8(%rbp)
jne    158d <main+0x3fd>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xb8b(%rip),%rdx
call   1080 <getopt@plt>
mov    %eax,-0x3b4(%rbp)
cmp    $0xffffffff,%eax
je     1588 <main+0x3f8>
mov    -0x3b4(%rbp),%eax
sub    $0x73,%eax
jne    157e <main+0x3ee>
jmp    1572 <main+0x3e2>
mov    $0x0,%al
call   10b0 <displayExtendedStats@plt>
jmp    1583 <main+0x3f3>
jmp    1583 <main+0x3f3>
jmp    1588 <main+0x3f8>
jmp    158d <main+0x3fd>
mov    -0x4(%rbp),%eax
add    $0x600,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x518,%rsp
mov    %rsi,%r13
mov    %edi,%r15d
lea    0xf20(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e1e(%rip),%r12
mov    (%r12),%esi
lea    0xe2b(%rip),%rdi
call   1070 <open@plt>
test   %eax,%eax
js     14bb <main+0x31b>
lea    0x110(%rsp),%rsi
mov    %eax,%edi
mov    $0x200,%edx
call   1050 <read@plt>
test   %eax,%eax
mov    %r15d,0xc(%rsp)
jle    12d8 <main+0x138>
mov    %eax,0x14(%rsp)
mov    %r13,0x18(%rsp)
lea    0x54(%rsp),%r14
lea    0x48(%rsp),%r15
lea    0x3c(%rsp),%r12
lea    0x30(%rsp),%r13
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    (%rsp,%rbp,1),%rbx
add    $0x110,%rbx
mov    %rbx,%rdi
lea    0xdd2(%rip),%rsi
lea    0x11(%rsp),%rdx
xor    %eax,%eax
call   1060 <sscanf@plt>
lea    0x24(%rsp),%rax
mov    %rax,(%rsp)
mov    %rbx,%rdi
lea    0xdc1(%rip),%rsi
mov    %r14,%rdx
mov    %r15,%rcx
mov    %r12,%r8
mov    %r13,%r9
xor    %eax,%eax
call   1060 <sscanf@plt>
add    $0x1,%rbp
cmp    $0x46,%rbp
jne    1230 <main+0x90>
lea    0xdb8(%rip),%rdi
lea    0x54(%rsp),%rsi
lea    0x48(%rsp),%rdx
lea    0x3c(%rsp),%rcx
lea    0x30(%rsp),%r8
lea    0x24(%rsp),%r9
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x11(%rsp),%rdi
call   10a0 <atoi@plt>
lea    0x1(%rax),%esi
lea    0xd99(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rsp),%r13
mov    0xc(%rsp),%r15d
mov    0x2d14(%rip),%r12
mov    0x14(%rsp),%eax
test   %eax,%eax
js     14c4 <main+0x324>
mov    (%r12),%esi
lea    0xd90(%rip),%rdi
call   1070 <open@plt>
test   %eax,%eax
js     14bb <main+0x31b>
mov    %eax,%ebx
lea    0x310(%rsp),%rsi
mov    %eax,%edi
mov    $0x200,%edx
call   1050 <read@plt>
test   %eax,%eax
jle    1358 <main+0x1b8>
lea    0xd70(%rip),%r14
lea    0x310(%rsp),%rbp
lea    0xc0(%rsp),%r15
nopl   0x0(%rax)
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1060 <sscanf@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x200,%edx
call   1050 <read@plt>
test   %eax,%eax
jg     1330 <main+0x190>
mov    0xc(%rsp),%r15d
test   %eax,%eax
js     14c4 <main+0x324>
lea    0xd34(%rip),%rdi
lea    0xc0(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r12),%esi
lea    0xd2f(%rip),%rdi
call   1070 <open@plt>
test   %eax,%eax
js     14bb <main+0x31b>
lea    0x80(%rsp),%rsi
mov    %eax,%edi
mov    $0x14,%edx
call   1050 <read@plt>
test   %eax,%eax
jle    13c9 <main+0x229>
lea    0xc8d(%rip),%rsi
lea    0x80(%rsp),%rdi
lea    0x60(%rsp),%rdx
lea    0xa0(%rsp),%rcx
xor    %eax,%eax
call   1060 <sscanf@plt>
lea    0x60(%rsp),%rdi
call   10a0 <atoi@plt>
movslq %eax,%r8
imul   $0xffffffffc22e4507,%r8,%rsi
shr    $0x20,%rsi
add    %r8d,%esi
mov    %esi,%eax
shr    $0x1f,%eax
sar    $0x10,%esi
add    %eax,%esi
imul   $0x15180,%esi,%eax
mov    %r8d,%ecx
sub    %eax,%ecx
movslq %ecx,%rdx
imul   $0xffffffff91a2b3c5,%rdx,%rax
shr    $0x20,%rax
add    %eax,%edx
mov    %edx,%eax
shr    $0x1f,%eax
sar    $0xb,%edx
add    %eax,%edx
imul   $0xffffffff91a2b3c5,%r8,%rax
shr    $0x20,%rax
add    %r8d,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0xb,%eax
add    %ecx,%eax
imul   $0xe10,%eax,%eax
mov    %r8d,%ecx
sub    %eax,%ecx
movswl %cx,%eax
imul   $0xffff8889,%eax,%eax
shr    $0x10,%eax
add    %ecx,%eax
movzwl %ax,%eax
movswl %ax,%ecx
shr    $0xf,%eax
sar    $0x5,%ecx
add    %eax,%ecx
movswl %cx,%ecx
imul   $0xffffffff88888889,%r8,%rax
shr    $0x20,%rax
add    %r8d,%eax
mov    %eax,%edi
shr    $0x1f,%edi
sar    $0x5,%eax
add    %edi,%eax
imul   $0x3c,%eax,%eax
sub    %eax,%r8d
lea    0xc43(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x2,%r15d
jne    14a7 <main+0x307>
lea    0xc0b(%rip),%rdx
mov    $0x2,%edi
mov    %r13,%rsi
call   1090 <getopt@plt>
cmp    $0x73,%eax
jne    14a7 <main+0x307>
xor    %eax,%eax
call   10c0 <displayExtendedStats@plt>
xor    %eax,%eax
add    $0x518,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xb4c(%rip),%rdi
jmp    14cb <main+0x32b>
lea    0xba7(%rip),%rdi
call   1080 <perror@plt>
mov    $0xffffffff,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [60 x i8] c"Welcome to Tom Pretto's Hardware Status Program (mystats)!\0A\00"
@.str.1 = [14 x i8] c"/proc/cpuinfo\00"
@O_RDONLY = global i32 0
@.str.2 = [9 x i8] c"Bad open\00"
@.str.3 = [14 x i8] c"processor\09:%s\00"
@.str.4 = [27 x i8] c"model name\09:%s %s %s %s %s\00"
@.str.5 = [21 x i8] c"cpu:\09%s %s %s %s %s\0A\00"
@.str.6 = [29 x i8] c"Number of processors: [%d]\0A\00"
@.str.7 = [9 x i8] c"Bad read\00"
@.str.8 = [14 x i8] c"/proc/version\00"
@.str.9 = [18 x i8] c"Linux version %s\00"
@.str.10 = [21 x i8] c"Kernel version: %s\0A\00"
@.str.11 = [13 x i8] c"/proc/uptime\00"
@.str.12 = [6 x i8] c"%s %s\00"
@.str.13 = [33 x i8] c"System up for %d:%.2d:%.2d:%.2d\0A\00"
@.str.14 = [2 x i8] c"s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [512 x i8]
%7 = alloca [20 x i8]
%8 = alloca [20 x i8]
%9 = alloca [20 x i8]
%10 = alloca [12 x i8]
%11 = alloca [12 x i8]
%12 = alloca [12 x i8]
%13 = alloca [12 x i8]
%14 = alloca [12 x i8]
%15 = alloca [12 x i8]
%16 = alloca [3 x i8]
%17 = alloca [80 x i8]
%18 = alloca [80 x i8]
%19 = alloca [12 x i8]
%20 = alloca [12 x i8]
%21 = alloca [12 x i8]
%22 = alloca [12 x i8]
%23 = alloca [12 x i8]
%24 = alloca [12 x i8]
%25 = alloca i32
%26 = alloca i32
%27 = alloca i32
%28 = alloca i32
%29 = alloca i32
%30 = alloca i32
%31 = alloca i32
%32 = alloca i32
%33 = alloca i32
%34 = alloca [512 x i8]
%35 = alloca i32
%36 = alloca i32
%37 = alloca i32
%38 = alloca i32
%39 = alloca i64
%40 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0))
%42 = load i32, i32* @O_RDONLY
%43 = call i32 @open(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %42)
store i32 %43, i32* %33
%44 = icmp slt i32 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %2
%46 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%47 = call i32 @exit(i32 -1)
unreachable
48: ; preds = %2
%49 = load i32, i32* %33
%50 = getelementptr inbounds [512 x i8], [512 x i8]* %34, i64 0, i64 0
%51 = call i32 @read(i32 %49, i8* %50, i32 512)
store i32 %51, i32* %37
%52 = icmp sgt i32 %51, 0
br i1 %52, label %53, label %87
53: ; preds = %48
store i32 0, i32* %38
br label %54
54: ; preds = %72, %53
%55 = load i32, i32* %38
%56 = icmp slt i32 %55, 70
br i1 %56, label %57, label %75
57: ; preds = %54
%58 = load i32, i32* %38
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [512 x i8], [512 x i8]* %34, i64 0, i64 %59
%61 = getelementptr inbounds [3 x i8], [3 x i8]* %16, i64 0, i64 0
%62 = call i32 (i8*, i8*, i8*, ...) @sscanf(i8* %60, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %61)
%63 = load i32, i32* %38
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [512 x i8], [512 x i8]* %34, i64 0, i64 %64
%66 = getelementptr inbounds [12 x i8], [12 x i8]* %19, i64 0, i64 0
%67 = getelementptr inbounds [12 x i8], [12 x i8]* %20, i64 0, i64 0
%68 = getelementptr inbounds [12 x i8], [12 x i8]* %21, i64 0, i64 0
%69 = getelementptr inbounds [12 x i8], [12 x i8]* %22, i64 0, i64 0
%70 = getelementptr inbounds [12 x i8], [12 x i8]* %23, i64 0, i64 0
%71 = call i32 (i8*, i8*, i8*, ...) @sscanf(i8* %65, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* %66, i8* %67, i8* %68, i8* %69, i8* %70)
br label %72
72: ; preds = %57
%73 = load i32, i32* %38
%74 = add nsw i32 %73, 1
store i32 %74, i32* %38
br label %54
75: ; preds = %54
%76 = getelementptr inbounds [12 x i8], [12 x i8]* %19, i64 0, i64 0
%77 = getelementptr inbounds [12 x i8], [12 x i8]* %20, i64 0, i64 0
%78 = getelementptr inbounds [12 x i8], [12 x i8]* %21, i64 0, i64 0
%79 = getelementptr inbounds [12 x i8], [12 x i8]* %22, i64 0, i64 0
%80 = getelementptr inbounds [12 x i8], [12 x i8]* %23, i64 0, i64 0
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* %76, i8* %77, i8* %78, i8* %79, i8* %80)
%82 = getelementptr inbounds [3 x i8], [3 x i8]* %16, i64 0, i64 0
%83 = call i32 @atoi(i8* %82)
store i32 %83, i32* %26
%84 = load i32, i32* %26
%85 = add nsw i32 %84, 1
store i32 %85, i32* %26
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i32 %85)
br label %87
87: ; preds = %75, %48
%88 = load i32, i32* %37
%89 = icmp slt i32 %88, 0
br i1 %89, label %90, label %93
90: ; preds = %87
%91 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%92 = call i32 @exit(i32 -1)
unreachable
93: ; preds = %87
%94 = load i32, i32* @O_RDONLY
%95 = call i32 @open(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), i32 %94)
store i32 %95, i32* %25
%96 = icmp slt i32 %95, 0
br i1 %96, label %97, label %100
97: ; preds = %93
%98 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%99 = call i32 @exit(i32 -1)
unreachable
100: ; preds = %93
br label %101
101: ; preds = %106, %100
%102 = load i32, i32* %25
%103 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%104 = call i32 @read(i32 %102, i8* %103, i32 512)
store i32 %104, i32* %37
%105 = icmp sgt i32 %104, 0
br i1 %105, label %106, label %110
106: ; preds = %101
%107 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%108 = getelementptr inbounds [80 x i8], [80 x i8]* %17, i64 0, i64 0
%109 = call i32 (i8*, i8*, i8*, ...) @sscanf(i8* %107, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i8* %108)
br label %101
110: ; preds = %101
%111 = load i32, i32* %37
%112 = icmp slt i32 %111, 0
br i1 %112, label %113, label %116
113: ; preds = %110
%114 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%115 = call i32 @exit(i32 -1)
unreachable
116: ; preds = %110
%117 = getelementptr inbounds [80 x i8], [80 x i8]* %17, i64 0, i64 0
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0), i8* %117)
br label %119
119: ; preds = %116
%120 = load i32, i32* @O_RDONLY
%121 = call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0), i32 %120)
store i32 %121, i32* %35
%122 = icmp slt i32 %121, 0
br i1 %122, label %123, label %126
123: ; preds = %119
%124 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%125 = call i32 @exit(i32 -1)
unreachable
126: ; preds = %119
%127 = load i32, i32* %37
%128 = icmp slt i32 %127, 0
br i1 %128, label %129, label %132
129: ; preds = %126
%130 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%131 = call i32 @exit(i32 -1)
unreachable
132: ; preds = %126
%133 = load i32, i32* %35
%134 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%135 = call i32 @read(i32 %133, i8* %134, i32 20)
store i32 %135, i32* %37
%136 = icmp sgt i32 %135, 0
br i1 %136, label %137, label %142
137: ; preds = %132
%138 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%139 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%140 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 0
%141 = call i32 (i8*, i8*, i8*, ...) @sscanf(i8* %138, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0), i8* %139, i8* %140)
br label %142
142: ; preds = %137, %132
%143 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%144 = call i32 @atoi(i8* %143)
store i32 %144, i32* %28
%145 = load i32, i32* %28
%146 = sdiv i32 %145, 86400
store i32 %146, i32* %31
%147 = load i32, i32* %28
%148 = srem i32 %147, 86400
%149 = sdiv i32 %148, 3600
store i32 %149, i32* %30
%150 = load i32, i32* %28
%151 = srem i32 %150, 3600
%152 = sdiv i32 %151, 60
store i32 %152, i32* %29
%153 = load i32, i32* %28
%154 = srem i32 %153, 60
store i32 %154, i32* %28
%155 = load i32, i32* %31
%156 = load i32, i32* %30
%157 = load i32, i32* %29
%158 = load i32, i32* %28
%159 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.13, i64 0, i64 0), i32 %155, i32 %156, i32 %157, i32 %158)
%160 = load i32, i32* %4
%161 = icmp eq i32 %160, 2
br i1 %161, label %162, label %174
162: ; preds = %142
%163 = load i32, i32* %4
%164 = load i8**, i8*** %5
%165 = call i32 @getopt(i32 %163, i8** %164, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
store i32 %165, i32* %27
%166 = icmp ne i32 %165, -1
br i1 %166, label %167, label %173
167: ; preds = %162
%168 = load i32, i32* %27
switch i32 %168, label %171 [
i32 115, label %169
]
169: ; preds = %167
%170 = call i32 (...) @displayExtendedStats()
br label %172
171: ; preds = %167
br label %172
172: ; preds = %171, %169
br label %173
173: ; preds = %172, %162
br label %174
174: ; preds = %173, %142
%175 = load i32, i32* %3
ret i32 %175
}

LLVM IR (-O2):
@.str.1 = [14 x i8] c"/proc/cpuinfo\00"
@O_RDONLY = global i32 0
@.str.2 = [9 x i8] c"Bad open\00"
@.str.3 = [14 x i8] c"processor\09:%s\00"
@.str.4 = [27 x i8] c"model name\09:%s %s %s %s %s\00"
@.str.5 = [21 x i8] c"cpu:\09%s %s %s %s %s\0A\00"
@.str.6 = [29 x i8] c"Number of processors: [%d]\0A\00"
@.str.7 = [9 x i8] c"Bad read\00"
@.str.8 = [14 x i8] c"/proc/version\00"
@.str.9 = [18 x i8] c"Linux version %s\00"
@.str.10 = [21 x i8] c"Kernel version: %s\0A\00"
@.str.11 = [13 x i8] c"/proc/uptime\00"
@.str.12 = [6 x i8] c"%s %s\00"
@.str.13 = [33 x i8] c"System up for %d:%.2d:%.2d:%.2d\0A\00"
@.str.14 = [2 x i8] c"s\00"
@str = [59 x i8] c"Welcome to Tom Pretto's Hardware Status Program (mystats)!\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [512 x i8]
%4 = alloca [20 x i8]
%5 = alloca [20 x i8]
%6 = alloca [20 x i8]
%7 = alloca [3 x i8]
%8 = alloca [80 x i8]
%9 = alloca [12 x i8]
%10 = alloca [12 x i8]
%11 = alloca [12 x i8]
%12 = alloca [12 x i8]
%13 = alloca [12 x i8]
%14 = alloca [512 x i8]
%15 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%17 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%19 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 0
%20 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%21 = getelementptr inbounds [12 x i8], [12 x i8]* %9, i64 0, i64 0
%22 = getelementptr inbounds [12 x i8], [12 x i8]* %10, i64 0, i64 0
%23 = getelementptr inbounds [12 x i8], [12 x i8]* %11, i64 0, i64 0
%24 = getelementptr inbounds [12 x i8], [12 x i8]* %12, i64 0, i64 0
%25 = getelementptr inbounds [12 x i8], [12 x i8]* %13, i64 0, i64 0
%26 = getelementptr inbounds [512 x i8], [512 x i8]* %14, i64 0, i64 0
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str, i64 0, i64 0))
%28 = load i32, i32* @O_RDONLY
%29 = tail call i32 @open(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %28)
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %2
%32 = tail call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%33 = tail call i32 @exit(i32 -1)
unreachable
34: ; preds = %2
%35 = call i32 @read(i32 %29, i8* %26, i32 512)
%36 = icmp sgt i32 %35, 0
br i1 %36, label %37, label %49
37: ; preds = %34, %37
%38 = phi i64 [ %42, %37 ], [ 0, %34 ]
%39 = getelementptr inbounds [512 x i8], [512 x i8]* %14, i64 0, i64 %38
%40 = call i32 (i8*, i8*, i8*, ...) @sscanf(i8* %39, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %19)
%41 = call i32 (i8*, i8*, i8*, ...) @sscanf(i8* %39, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* %21, i8* %22, i8* %23, i8* %24, i8* %25)
%42 = add nuw nsw i64 %38, 1
%43 = icmp eq i64 %42, 70
br i1 %43, label %44, label %37
44: ; preds = %37
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* %21, i8* %22, i8* %23, i8* %24, i8* %25)
%46 = call i32 @atoi(i8* %19)
%47 = add nsw i32 %46, 1
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i32 %47)
br label %49
49: ; preds = %44, %34
%50 = icmp slt i32 %35, 0
br i1 %50, label %51, label %54
51: ; preds = %49
%52 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%53 = call i32 @exit(i32 -1)
unreachable
54: ; preds = %49
%55 = load i32, i32* @O_RDONLY
%56 = call i32 @open(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), i32 %55)
%57 = icmp slt i32 %56, 0
br i1 %57, label %61, label %58
58: ; preds = %54
%59 = call i32 @read(i32 %56, i8* %15, i32 512)
%60 = icmp sgt i32 %59, 0
br i1 %60, label %64, label %68
61: ; preds = %54
%62 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%63 = call i32 @exit(i32 -1)
unreachable
64: ; preds = %58, %64
%65 = call i32 (i8*, i8*, i8*, ...) @sscanf(i8* %15, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i8* %20)
%66 = call i32 @read(i32 %56, i8* %15, i32 512)
%67 = icmp sgt i32 %66, 0
br i1 %67, label %64, label %68
68: ; preds = %64, %58
%69 = phi i32 [ %59, %58 ], [ %66, %64 ]
%70 = icmp slt i32 %69, 0
br i1 %70, label %71, label %74
71: ; preds = %68
%72 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%73 = call i32 @exit(i32 -1)
unreachable
74: ; preds = %68
%75 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0), i8* %20)
%76 = load i32, i32* @O_RDONLY
%77 = call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0), i32 %76)
%78 = icmp slt i32 %77, 0
br i1 %78, label %79, label %82
79: ; preds = %74
%80 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%81 = call i32 @exit(i32 -1)
unreachable
82: ; preds = %74
%83 = call i32 @read(i32 %77, i8* %16, i32 20)
%84 = icmp sgt i32 %83, 0
br i1 %84, label %85, label %87
85: ; preds = %82
%86 = call i32 (i8*, i8*, i8*, ...) @sscanf(i8* %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0), i8* %17, i8* %18)
br label %87
87: ; preds = %85, %82
%88 = call i32 @atoi(i8* %17)
%89 = sdiv i32 %88, 86400
%90 = srem i32 %88, 86400
%91 = sdiv i32 %90, 3600
%92 = srem i32 %88, 3600
%93 = trunc i32 %92 to i16
%94 = sdiv i16 %93, 60
%95 = sext i16 %94 to i32
%96 = srem i32 %88, 60
%97 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.13, i64 0, i64 0), i32 %89, i32 %91, i32 %95, i32 %96)
%98 = icmp eq i32 %0, 2
br i1 %98, label %99, label %104
99: ; preds = %87
%100 = call i32 @getopt(i32 2, i8** %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
%101 = icmp eq i32 %100, 115
br i1 %101, label %102, label %104
102: ; preds = %99
%103 = call i32 (...) @displayExtendedStats()
br label %104
104: ; preds = %99, %102, %87
ret i32 0
}