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

/* Variables and functions */
int /*<<< orphan*/ addch(char);
int /*<<< orphan*/ cbreak();
int /*<<< orphan*/ curs_set(int /*<<< orphan*/);
int /*<<< orphan*/ endwin();
int getch();
scalar_t__ gpioInitialise();
int /*<<< orphan*/ gpioTerminate();
int /*<<< orphan*/ i2cClose(int);
int i2cOpen(int, int, int /*<<< orphan*/);
unsigned char i2cReadByte(int);
int /*<<< orphan*/ i2cWriteDevice(int, unsigned char **, int);
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ move(int, int);
int /*<<< orphan*/ mvaddstr(int, int, ...);
int /*<<< orphan*/ nodelay(int /*<<< orphan*/, int);
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ printw(char *);
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ sprintf(unsigned char *, char *, unsigned char);
int /*<<< orphan*/ stdscr;
int /*<<< orphan*/ usleep(int);
int main(int argc, char *argv[]) {
  int i;
  int r;
  int handle;
  char aout;
  unsigned char command[2];
  unsigned char value[4];
  unsigned char str[8];
  int j;
  int key;
  if (gpioInitialise() < 0)
    return 1;
  initscr();
  noecho();
  cbreak();
  nodelay(stdscr, true);
  curs_set(0);
  printw("PCF8591 + or - to change aout, any other key to quit.");
  mvaddstr(10, 0, "Brightness");
  mvaddstr(12, 0, "Temperature");
  mvaddstr(14, 0, "?");
  mvaddstr(16, 0, "Resistor");
  refresh();
  handle = i2cOpen(1, 0x48, 0);
  command[1] = 0;
  aout = 128;
  while (1) {
    for (i = 0; i < 4; i++) {
      command[1] = aout;
      command[0] = 0x40 | ((i + 1) & 0x03);
      i2cWriteDevice(handle, &command, 2);
      usleep(20000);
      value[i] = i2cReadByte(handle);
      sprintf(str, "%3d", value[i]);
      mvaddstr(10 + i + i, 12, str);
      value[i] = value[i] / 4;
      move(10 + i + i, 16);
      for (j = 0; j < 64; j++)
        if (j < value[i])
          addch('*');
        else
          addch(' ');
    }
    refresh();
    key = getch();
    if ((key == '+') || (key == '='))
      aout++;
    else if ((key == '-') || (key == '_'))
      aout--;
    else if (key != -1)
      break;
  }
  endwin();
  i2cClose(handle);
  gpioTerminate();
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1050 <gpioInitialise@plt>
cmp    $0x0,%rax
jge    1273 <main+0x33>
movl   $0x1,-0x4(%rbp)
jmp    14ca <main+0x28a>
mov    $0x0,%al
call   1040 <initscr@plt>
mov    $0x0,%al
call   10f0 <noecho@plt>
mov    $0x0,%al
call   1030 <cbreak@plt>
mov    0x2d59(%rip),%rax
mov    (%rax),%edi
mov    $0x1,%esi
call   1090 <nodelay@plt>
xor    %edi,%edi
call   1140 <curs_set@plt>
lea    0xd57(%rip),%rdi
call   1080 <printw@plt>
mov    $0xa,%edi
xor    %esi,%esi
lea    0xd7a(%rip),%rdx
mov    $0x0,%al
call   1100 <mvaddstr@plt>
mov    $0xc,%edi
xor    %esi,%esi
lea    0xd70(%rip),%rdx
mov    $0x0,%al
call   1100 <mvaddstr@plt>
mov    $0xe,%edi
xor    %esi,%esi
lea    0xd67(%rip),%rdx
mov    $0x0,%al
call   1100 <mvaddstr@plt>
mov    $0x10,%edi
xor    %esi,%esi
lea    0xd54(%rip),%rdx
mov    $0x0,%al
call   1100 <mvaddstr@plt>
mov    $0x0,%al
call   10c0 <refresh@plt>
mov    $0x1,%edi
mov    $0x48,%esi
xor    %edx,%edx
call   1130 <i2cOpen@plt>
mov    %eax,-0x1c(%rbp)
movb   $0x0,-0x1e(%rbp)
movb   $0x80,-0x1d(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    143c <main+0x1fc>
mov    -0x1d(%rbp),%al
mov    %al,-0x1e(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
and    $0x3,%eax
or     $0x40,%eax
mov    %al,-0x1f(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x1f(%rbp),%rsi
mov    $0x2,%edx
call   1070 <i2cWriteDevice@plt>
mov    $0x4e20,%edi
call   1150 <usleep@plt>
mov    -0x1c(%rbp),%edi
call   1060 <i2cReadByte@plt>
mov    %al,%cl
movslq -0x14(%rbp),%rax
mov    %cl,-0x23(%rbp,%rax,1)
lea    -0x2b(%rbp),%rdi
movslq -0x14(%rbp),%rax
lea    0xcd1(%rip),%rsi
movzbl -0x23(%rbp,%rax,1),%edx
call   1120 <sprintf@plt>
mov    -0x14(%rbp),%edi
add    $0xa,%edi
add    -0x14(%rbp),%edi
lea    -0x2b(%rbp),%rdx
mov    $0xc,%esi
mov    $0x0,%al
call   1100 <mvaddstr@plt>
movslq -0x14(%rbp),%rax
movzbl -0x23(%rbp,%rax,1),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %al,%cl
movslq -0x14(%rbp),%rax
mov    %cl,-0x23(%rbp,%rax,1)
mov    -0x14(%rbp),%edi
add    $0xa,%edi
add    -0x14(%rbp),%edi
mov    $0x10,%esi
call   1160 <move@plt>
movl   $0x0,-0x30(%rbp)
cmpl   $0x40,-0x30(%rbp)
jge    1429 <main+0x1e9>
mov    -0x30(%rbp),%eax
movslq -0x14(%rbp),%rcx
movzbl -0x23(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
jge    140c <main+0x1cc>
mov    $0x2a,%edi
call   10b0 <addch@plt>
jmp    1416 <main+0x1d6>
mov    $0x20,%edi
call   10b0 <addch@plt>
jmp    141b <main+0x1db>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    13df <main+0x19f>
jmp    142e <main+0x1ee>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    132c <main+0xec>
mov    $0x0,%al
call   10c0 <refresh@plt>
mov    $0x0,%al
call   10d0 <getch@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x2b,-0x34(%rbp)
je     1461 <main+0x221>
cmpl   $0x3d,-0x34(%rbp)
jne    146e <main+0x22e>
mov    -0x1d(%rbp),%al
add    $0x1,%al
mov    %al,-0x1d(%rbp)
jmp    14a8 <main+0x268>
cmpl   $0x2d,-0x34(%rbp)
je     1482 <main+0x242>
cmpl   $0x5f,-0x34(%rbp)
jne    148f <main+0x24f>
mov    -0x1d(%rbp),%al
add    $0xff,%al
mov    %al,-0x1d(%rbp)
jmp    14a3 <main+0x263>
cmpl   $0xffffffff,-0x34(%rbp)
je     149e <main+0x25e>
jmp    14ad <main+0x26d>
jmp    14a3 <main+0x263>
jmp    14a8 <main+0x268>
jmp    1325 <main+0xe5>
mov    $0x0,%al
call   10e0 <endwin@plt>
mov    -0x1c(%rbp),%edi
call   10a0 <i2cClose@plt>
mov    $0x0,%al
call   1110 <gpioTerminate@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
xor    %eax,%eax
call   1050 <gpioInitialise@plt>
test   %rax,%rax
js     15f1 <main+0x3b1>
xor    %eax,%eax
call   1040 <initscr@plt>
xor    %eax,%eax
call   10f0 <noecho@plt>
xor    %eax,%eax
call   1030 <cbreak@plt>
mov    0x2d6e(%rip),%rax
mov    (%rax),%edi
mov    $0x1,%esi
call   1090 <nodelay@plt>
xor    %edi,%edi
call   1140 <curs_set@plt>
lea    0xd6c(%rip),%rdi
call   1080 <printw@plt>
lea    0xd96(%rip),%rdx
mov    $0xa,%edi
xor    %esi,%esi
xor    %eax,%eax
call   1100 <mvaddstr@plt>
lea    0xd8c(%rip),%rdx
mov    $0xc,%edi
xor    %esi,%esi
xor    %eax,%eax
call   1100 <mvaddstr@plt>
lea    0xd83(%rip),%rdx
mov    $0xe,%edi
xor    %esi,%esi
xor    %eax,%eax
call   1100 <mvaddstr@plt>
lea    0xd70(%rip),%rdx
mov    $0x10,%edi
xor    %esi,%esi
xor    %eax,%eax
call   1100 <mvaddstr@plt>
xor    %eax,%eax
call   10c0 <refresh@plt>
mov    $0x1,%edi
mov    $0x48,%esi
xor    %edx,%edx
call   1130 <i2cOpen@plt>
mov    %eax,%r12d
mov    $0x80,%r13b
lea    0xd(%rsp),%rsi
mov    $0x2a,%r14d
jmp    1324 <main+0xe4>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r13b
mov    %r13b,0xf(%rsp)
nopl   0x0(%rax)
mov    %r13b,0xe(%rsp)
movb   $0x41,0xd(%rsp)
mov    %r12d,%edi
mov    %rsi,%r13
mov    $0x2,%edx
call   1070 <i2cWriteDevice@plt>
mov    $0x4e20,%edi
call   1150 <usleep@plt>
mov    %r12d,%edi
call   1060 <i2cReadByte@plt>
movzbl %al,%ebp
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
lea    0xcea(%rip),%rsi
mov    %ebp,%edx
call   1120 <sprintf@plt>
xor    %r15d,%r15d
mov    $0xa,%edi
mov    $0xc,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1100 <mvaddstr@plt>
shr    $0x2,%bpl
mov    $0xa,%edi
mov    $0x10,%esi
call   1160 <move@plt>
movzbl %bpl,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    %ebx,%r15d
mov    $0x20,%edi
cmovb  %r14d,%edi
call   10b0 <addch@plt>
add    $0x1,%r15d
cmp    $0x40,%r15d
jne    13b0 <main+0x170>
mov    0xf(%rsp),%al
mov    %al,0xe(%rsp)
movb   $0x42,0xd(%rsp)
mov    %r12d,%edi
mov    %r13,%r15
mov    %r13,%rsi
mov    $0x2,%edx
call   1070 <i2cWriteDevice@plt>
mov    $0x4e20,%edi
call   1150 <usleep@plt>
mov    %r12d,%edi
call   1060 <i2cReadByte@plt>
movzbl %al,%ebp
lea    0x10(%rsp),%r13
mov    %r13,%rdi
lea    0xc49(%rip),%rsi
mov    %ebp,%edx
call   1120 <sprintf@plt>
xor    %ebx,%ebx
mov    $0xc,%edi
mov    $0xc,%esi
mov    %r13,%rdx
xor    %eax,%eax
call   1100 <mvaddstr@plt>
shr    $0x2,%bpl
mov    $0xc,%edi
mov    $0x10,%esi
call   1160 <move@plt>
movzbl %bpl,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    %ebp,%ebx
mov    $0x20,%edi
cmovb  %r14d,%edi
call   10b0 <addch@plt>
add    $0x1,%ebx
cmp    $0x40,%ebx
jne    1450 <main+0x210>
mov    0xf(%rsp),%r13b
mov    %r13b,0xe(%rsp)
movb   $0x43,0xd(%rsp)
mov    %r12d,%edi
mov    %r15,%rsi
mov    $0x2,%edx
call   1070 <i2cWriteDevice@plt>
mov    $0x4e20,%edi
call   1150 <usleep@plt>
mov    %r12d,%edi
call   1060 <i2cReadByte@plt>
movzbl %al,%ebp
lea    0x10(%rsp),%r15
mov    %r15,%rdi
lea    0xbad(%rip),%rsi
mov    %ebp,%edx
call   1120 <sprintf@plt>
xor    %ebx,%ebx
mov    $0xe,%edi
mov    $0xc,%esi
mov    %r15,%rdx
xor    %eax,%eax
call   1100 <mvaddstr@plt>
shr    $0x2,%bpl
mov    $0xe,%edi
mov    $0x10,%esi
call   1160 <move@plt>
movzbl %bpl,%ebp
nop
cmp    %ebp,%ebx
mov    $0x20,%edi
cmovb  %r14d,%edi
call   10b0 <addch@plt>
add    $0x1,%ebx
cmp    $0x40,%ebx
jne    14e0 <main+0x2a0>
mov    %r13b,0xe(%rsp)
movb   $0x40,0xd(%rsp)
mov    %r12d,%edi
lea    0xd(%rsp),%rsi
mov    $0x2,%edx
call   1070 <i2cWriteDevice@plt>
mov    $0x4e20,%edi
call   1150 <usleep@plt>
mov    %r12d,%edi
call   1060 <i2cReadByte@plt>
movzbl %al,%ebp
lea    0x10(%rsp),%r15
mov    %r15,%rdi
lea    0xb20(%rip),%rsi
mov    %ebp,%edx
call   1120 <sprintf@plt>
xor    %ebx,%ebx
mov    $0x10,%edi
mov    $0xc,%esi
mov    %r15,%rdx
xor    %eax,%eax
call   1100 <mvaddstr@plt>
shr    $0x2,%bpl
mov    $0x10,%edi
mov    $0x10,%esi
call   1160 <move@plt>
movzbl %bpl,%ebp
nopl   0x0(%rax)
cmp    %ebp,%ebx
mov    $0x20,%edi
cmovb  %r14d,%edi
call   10b0 <addch@plt>
add    $0x1,%ebx
cmp    $0x40,%ebx
jne    1570 <main+0x330>
xor    %eax,%eax
call   10c0 <refresh@plt>
xor    %eax,%eax
call   10d0 <getch@plt>
cmp    $0xffffffff,%eax
lea    0xd(%rsp),%rsi
je     1330 <main+0xf0>
cmp    $0x3c,%eax
jg     15c0 <main+0x380>
cmp    $0x2b,%eax
je     1320 <main+0xe0>
cmp    $0x2d,%eax
je     15ce <main+0x38e>
jmp    15d7 <main+0x397>
nopl   0x0(%rax)
cmp    $0x3d,%eax
je     1320 <main+0xe0>
cmp    $0x5f,%eax
jne    15d7 <main+0x397>
add    $0xff,%r13b
jmp    1324 <main+0xe4>
xor    %ebp,%ebp
xor    %eax,%eax
call   10e0 <endwin@plt>
mov    %r12d,%edi
call   10a0 <i2cClose@plt>
xor    %eax,%eax
call   1110 <gpioTerminate@plt>
jmp    15f6 <main+0x3b6>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdscr = global i32 0
@.str = [54 x i8] c"PCF8591 + or - to change aout, any other key to quit.\00"
@.str.1 = [11 x i8] c"Brightness\00"
@.str.2 = [12 x i8] c"Temperature\00"
@.str.3 = [2 x i8] c"?\00"
@.str.4 = [9 x i8] c"Resistor\00"
@.str.5 = [4 x i8] c"%3d\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 i8
%10 = alloca [2 x i8]
%11 = alloca [4 x i8]
%12 = alloca [8 x i8]
%13 = alloca i32
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = call i64 (...) @gpioInitialise()
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %2
store i32 1, i32* %3
br label %137
18: ; preds = %2
%19 = call i32 (...) @initscr()
%20 = call i32 (...) @noecho()
%21 = call i32 (...) @cbreak()
%22 = load i32, i32* @stdscr
%23 = call i32 @nodelay(i32 %22, i32 1)
%24 = call i32 @curs_set(i32 0)
%25 = call i32 @printw(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%26 = call i32 (i32, i32, ...) @mvaddstr(i32 10, i32 0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%27 = call i32 (i32, i32, ...) @mvaddstr(i32 12, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%28 = call i32 (i32, i32, ...) @mvaddstr(i32 14, i32 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%29 = call i32 (i32, i32, ...) @mvaddstr(i32 16, i32 0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%30 = call i32 (...) @refresh()
%31 = call i32 @i2cOpen(i32 1, i32 72, i32 0)
store i32 %31, i32* %8
%32 = getelementptr inbounds [2 x i8], [2 x i8]* %10, i64 0, i64 1
store i8 0, i8* %32
store i8 -128, i8* %9
br label %33
33: ; preds = %18, %131
store i32 0, i32* %6
br label %34
34: ; preds = %102, %33
%35 = load i32, i32* %6
%36 = icmp slt i32 %35, 4
br i1 %36, label %37, label %105
37: ; preds = %34
%38 = load i8, i8* %9
%39 = getelementptr inbounds [2 x i8], [2 x i8]* %10, i64 0, i64 1
store i8 %38, i8* %39
%40 = load i32, i32* %6
%41 = add nsw i32 %40, 1
%42 = and i32 %41, 3
%43 = or i32 64, %42
%44 = trunc i32 %43 to i8
%45 = getelementptr inbounds [2 x i8], [2 x i8]* %10, i64 0, i64 0
store i8 %44, i8* %45
%46 = load i32, i32* %8
%47 = bitcast [2 x i8]* %10 to i8**
%48 = call i32 @i2cWriteDevice(i32 %46, i8** %47, i32 2)
%49 = call i32 @usleep(i32 20000)
%50 = load i32, i32* %8
%51 = call zeroext i8 @i2cReadByte(i32 %50)
%52 = load i32, i32* %6
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [4 x i8], [4 x i8]* %11, i64 0, i64 %53
store i8 %51, i8* %54
%55 = getelementptr inbounds [8 x i8], [8 x i8]* %12, i64 0, i64 0
%56 = load i32, i32* %6
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [4 x i8], [4 x i8]* %11, i64 0, i64 %57
%59 = load i8, i8* %58
%60 = call i32 @sprintf(i8* %55, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8 zeroext %59)
%61 = load i32, i32* %6
%62 = add nsw i32 10, %61
%63 = load i32, i32* %6
%64 = add nsw i32 %62, %63
%65 = getelementptr inbounds [8 x i8], [8 x i8]* %12, i64 0, i64 0
%66 = call i32 (i32, i32, ...) @mvaddstr(i32 %64, i32 12, i8* %65)
%67 = load i32, i32* %6
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [4 x i8], [4 x i8]* %11, i64 0, i64 %68
%70 = load i8, i8* %69
%71 = zext i8 %70 to i32
%72 = sdiv i32 %71, 4
%73 = trunc i32 %72 to i8
%74 = load i32, i32* %6
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds [4 x i8], [4 x i8]* %11, i64 0, i64 %75
store i8 %73, i8* %76
%77 = load i32, i32* %6
%78 = add nsw i32 10, %77
%79 = load i32, i32* %6
%80 = add nsw i32 %78, %79
%81 = call i32 @move(i32 %80, i32 16)
store i32 0, i32* %13
br label %82
82: ; preds = %98, %37
%83 = load i32, i32* %13
%84 = icmp slt i32 %83, 64
br i1 %84, label %85, label %101
85: ; preds = %82
%86 = load i32, i32* %13
%87 = load i32, i32* %6
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds [4 x i8], [4 x i8]* %11, i64 0, i64 %88
%90 = load i8, i8* %89
%91 = zext i8 %90 to i32
%92 = icmp slt i32 %86, %91
br i1 %92, label %93, label %95
93: ; preds = %85
%94 = call i32 @addch(i8 signext 42)
br label %97
95: ; preds = %85
%96 = call i32 @addch(i8 signext 32)
br label %97
97: ; preds = %95, %93
br label %98
98: ; preds = %97
%99 = load i32, i32* %13
%100 = add nsw i32 %99, 1
store i32 %100, i32* %13
br label %82
101: ; preds = %82
br label %102
102: ; preds = %101
%103 = load i32, i32* %6
%104 = add nsw i32 %103, 1
store i32 %104, i32* %6
br label %34
105: ; preds = %34
%106 = call i32 (...) @refresh()
%107 = call i32 (...) @getch()
store i32 %107, i32* %14
%108 = load i32, i32* %14
%109 = icmp eq i32 %108, 43
br i1 %109, label %113, label %110
110: ; preds = %105
%111 = load i32, i32* %14
%112 = icmp eq i32 %111, 61
br i1 %112, label %113, label %116
113: ; preds = %110, %105
%114 = load i8, i8* %9
%115 = add i8 %114, 1
store i8 %115, i8* %9
br label %131
116: ; preds = %110
%117 = load i32, i32* %14
%118 = icmp eq i32 %117, 45
br i1 %118, label %122, label %119
119: ; preds = %116
%120 = load i32, i32* %14
%121 = icmp eq i32 %120, 95
br i1 %121, label %122, label %125
122: ; preds = %119, %116
%123 = load i8, i8* %9
%124 = add i8 %123, -1
store i8 %124, i8* %9
br label %130
125: ; preds = %119
%126 = load i32, i32* %14
%127 = icmp ne i32 %126, -1
br i1 %127, label %128, label %129
128: ; preds = %125
br label %132
129: ; preds = %125
br label %130
130: ; preds = %129, %122
br label %131
131: ; preds = %130, %113
br label %33
132: ; preds = %128
%133 = call i32 (...) @endwin()
%134 = load i32, i32* %8
%135 = call i32 @i2cClose(i32 %134)
%136 = call i32 (...) @gpioTerminate()
store i32 0, i32* %3
br label %137
137: ; preds = %132, %17
%138 = load i32, i32* %3
ret i32 %138
}

LLVM IR (-O2):
@stdscr = global i32 0
@.str = [54 x i8] c"PCF8591 + or - to change aout, any other key to quit.\00"
@.str.1 = [11 x i8] c"Brightness\00"
@.str.2 = [12 x i8] c"Temperature\00"
@.str.3 = [2 x i8] c"?\00"
@.str.4 = [9 x i8] c"Resistor\00"
@.str.5 = [4 x i8] c"%3d\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [2 x i8]
%4 = alloca [8 x i8]
%5 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%7 = tail call i64 (...) @gpioInitialise()
%8 = icmp slt i64 %7, 0
br i1 %8, label %104, label %9
9: ; preds = %2
%10 = tail call i32 (...) @initscr()
%11 = tail call i32 (...) @noecho()
%12 = tail call i32 (...) @cbreak()
%13 = load i32, i32* @stdscr
%14 = tail call i32 @nodelay(i32 %13, i32 1)
%15 = tail call i32 @curs_set(i32 0)
%16 = tail call i32 @printw(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%17 = tail call i32 (i32, i32, ...) @mvaddstr(i32 10, i32 0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%18 = tail call i32 (i32, i32, ...) @mvaddstr(i32 12, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%19 = tail call i32 (i32, i32, ...) @mvaddstr(i32 14, i32 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%20 = tail call i32 (i32, i32, ...) @mvaddstr(i32 16, i32 0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%21 = tail call i32 (...) @refresh()
%22 = tail call i32 @i2cOpen(i32 1, i32 72, i32 0)
%23 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 1
%24 = bitcast [2 x i8]* %3 to i8**
br label %25
25: ; preds = %96, %9
%26 = phi i8 [ -128, %9 ], [ %97, %96 ]
br label %27
27: ; preds = %25, %84
store i8 %26, i8* %23
store i8 65, i8* %5
%28 = call i32 @i2cWriteDevice(i32 %22, i8** %24, i32 2)
%29 = call i32 @usleep(i32 20000)
%30 = call zeroext i8 @i2cReadByte(i32 %22)
%31 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8 zeroext %30)
%32 = call i32 (i32, i32, ...) @mvaddstr(i32 10, i32 12, i8* %6)
%33 = lshr i8 %30, 2
%34 = call i32 @move(i32 10, i32 16)
%35 = zext i8 %33 to i32
br label %87
36: ; preds = %87
store i8 %26, i8* %23
store i8 66, i8* %5
%37 = call i32 @i2cWriteDevice(i32 %22, i8** %24, i32 2)
%38 = call i32 @usleep(i32 20000)
%39 = call zeroext i8 @i2cReadByte(i32 %22)
%40 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8 zeroext %39)
%41 = call i32 (i32, i32, ...) @mvaddstr(i32 12, i32 12, i8* %6)
%42 = lshr i8 %39, 2
%43 = call i32 @move(i32 12, i32 16)
%44 = zext i8 %42 to i32
br label %45
45: ; preds = %45, %36
%46 = phi i32 [ 0, %36 ], [ %50, %45 ]
%47 = icmp ult i32 %46, %44
%48 = select i1 %47, i8 42, i8 32
%49 = call i32 @addch(i8 signext %48)
%50 = add nuw nsw i32 %46, 1
%51 = icmp eq i32 %50, 64
br i1 %51, label %52, label %45
52: ; preds = %45
store i8 %26, i8* %23
store i8 67, i8* %5
%53 = call i32 @i2cWriteDevice(i32 %22, i8** %24, i32 2)
%54 = call i32 @usleep(i32 20000)
%55 = call zeroext i8 @i2cReadByte(i32 %22)
%56 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8 zeroext %55)
%57 = call i32 (i32, i32, ...) @mvaddstr(i32 14, i32 12, i8* %6)
%58 = lshr i8 %55, 2
%59 = call i32 @move(i32 14, i32 16)
%60 = zext i8 %58 to i32
br label %61
61: ; preds = %61, %52
%62 = phi i32 [ 0, %52 ], [ %66, %61 ]
%63 = icmp ult i32 %62, %60
%64 = select i1 %63, i8 42, i8 32
%65 = call i32 @addch(i8 signext %64)
%66 = add nuw nsw i32 %62, 1
%67 = icmp eq i32 %66, 64
br i1 %67, label %68, label %61
68: ; preds = %61
store i8 %26, i8* %23
store i8 64, i8* %5
%69 = call i32 @i2cWriteDevice(i32 %22, i8** %24, i32 2)
%70 = call i32 @usleep(i32 20000)
%71 = call zeroext i8 @i2cReadByte(i32 %22)
%72 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8 zeroext %71)
%73 = call i32 (i32, i32, ...) @mvaddstr(i32 16, i32 12, i8* %6)
%74 = lshr i8 %71, 2
%75 = call i32 @move(i32 16, i32 16)
%76 = zext i8 %74 to i32
br label %77
77: ; preds = %77, %68
%78 = phi i32 [ 0, %68 ], [ %82, %77 ]
%79 = icmp ult i32 %78, %76
%80 = select i1 %79, i8 42, i8 32
%81 = call i32 @addch(i8 signext %80)
%82 = add nuw nsw i32 %78, 1
%83 = icmp eq i32 %82, 64
br i1 %83, label %84, label %77
84: ; preds = %77
%85 = call i32 (...) @refresh()
%86 = call i32 (...) @getch()
switch i32 %86, label %100 [
i32 61, label %94
i32 43, label %94
i32 95, label %98
i32 45, label %98
i32 -1, label %27
]
87: ; preds = %27, %87
%88 = phi i32 [ 0, %27 ], [ %92, %87 ]
%89 = icmp ult i32 %88, %35
%90 = select i1 %89, i8 42, i8 32
%91 = call i32 @addch(i8 signext %90)
%92 = add nuw nsw i32 %88, 1
%93 = icmp eq i32 %92, 64
br i1 %93, label %36, label %87
94: ; preds = %84, %84
%95 = add i8 %26, 1
br label %96
96: ; preds = %94, %98
%97 = phi i8 [ %99, %98 ], [ %95, %94 ]
br label %25
98: ; preds = %84, %84
%99 = add i8 %26, -1
br label %96
100: ; preds = %84
%101 = call i32 (...) @endwin()
%102 = call i32 @i2cClose(i32 %22)
%103 = call i32 (...) @gpioTerminate()
br label %104
104: ; preds = %2, %100
%105 = phi i32 [ 0, %100 ], [ 1, %2 ]
ret i32 %105
}