#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*/ at24c256_read(int, int, int, char *, int);
int /*<<< orphan*/ at24c256_write(int, int, int, char *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ free(char *);
int getopt(int, char **, char *);
int init_at24c256_i2c(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
char *optarg;
int /*<<< orphan*/ printf(char *, char *, int, ...);
int /*<<< orphan*/ show_usage(char **);
int sscanf(char *, char *, int *);
int /*<<< orphan*/ stderr;
int strlen(char *);
int /*<<< orphan*/ usleep(int);
int main(int argc, char *argv[]) {
  char *device = "/dev/i2c-1";
  int slave_address = 0x50;
  int offset = 0x00;
  int length = 32;
  char *data = NULL;
  int rw_mode = 1;
  if (argc == 1) {
    show_usage(argv);
    return 0;
  }
  int i;
  while ((i = getopt(argc, argv, "d:a:o:r:w:n:h")) >= 0) {
    switch (i) {
    case 'd':
      device = optarg;
      break;
    case 'a':
      if (sscanf(optarg, "0x%x", &slave_address) != 1) {
        fprintf(
            stderr,
            "Cannot parse '%s' as i2c slave device address, example: '0x50'\n",
            optarg);
        return -1;
      }
      break;
    case 'o':
      if (sscanf(optarg, "%d", &offset) != 1) {
        fprintf(stderr, "Cannot parse '%s' as address offset, example: '32'\n",
                optarg);
        return -1;
      }
      break;
    case 'r':
      rw_mode = 1;
      if (sscanf(optarg, "%d", &length) != 1) {
        fprintf(stderr, "Cannot parse '%s' as length, example: '17'\n", optarg);
        return -1;
      }
      break;
    case 'w':
      rw_mode = 0;
      data = optarg;
      length = strlen(data);
      break;
    case 'h':
      show_usage(argv);
      return 0;
      break;
    }
  }
  int fd = init_at24c256_i2c(device);
  if (fd < 0)
    return -1;
  printf("i2c device file:%s\nslave_address:0x%X\nR/W offset:0x%X\n", device,
         slave_address, offset);
  if (rw_mode == 0) {
    at24c256_write(fd, slave_address, offset, data, length);
    printf("try to write: %s (%d bytes)!\n", data, length);
    usleep(10000);
  } else if (rw_mode == 1) {
    char *buf = (char *)malloc(length + 1);
    memset(buf, 0, length + 1);
    at24c256_read(fd, slave_address, offset, buf, length);
    usleep(10000);
    printf("read from at24c256 eeprom: %s (%d bytes)\n", buf, strlen(buf));
    free(buf);
  }
  close(fd);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe5f(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x50,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x20,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0x1,-0x34(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1244 <main+0x64>
mov    -0x10(%rbp),%rdi
call   10e0 <show_usage@plt>
movl   $0x0,-0x4(%rbp)
jmp    14e7 <main+0x307>
jmp    1249 <main+0x69>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe10(%rip),%rdx
call   10f0 <getopt@plt>
mov    %eax,-0x38(%rbp)
cmp    $0x0,%eax
jl     13e4 <main+0x204>
mov    -0x38(%rbp),%eax
add    $0xffffff9f,%eax
mov    %eax,%ecx
mov    %rcx,-0x50(%rbp)
sub    $0x16,%eax
ja     13df <main+0x1ff>
mov    -0x50(%rbp),%rax
lea    0xd78(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2d60(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    13df <main+0x1ff>
mov    0x2d4d(%rip),%rax
mov    (%rax),%rdi
lea    0xdc0(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   10d0 <sscanf@plt>
cmp    $0x1,%eax
je     12f2 <main+0x112>
mov    0x2d0a(%rip),%rax
mov    (%rax),%edi
mov    0x2d21(%rip),%rax
mov    (%rax),%rdx
lea    0xd99(%rip),%rsi
call   10b0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14e7 <main+0x307>
jmp    13df <main+0x1ff>
mov    0x2cfa(%rip),%rax
mov    (%rax),%rdi
lea    0xdb2(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   10d0 <sscanf@plt>
cmp    $0x1,%eax
je     1345 <main+0x165>
mov    0x2cb7(%rip),%rax
mov    (%rax),%edi
mov    0x2cce(%rip),%rax
mov    (%rax),%rdx
lea    0xd89(%rip),%rsi
call   10b0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14e7 <main+0x307>
jmp    13df <main+0x1ff>
movl   $0x1,-0x34(%rbp)
mov    0x2ca0(%rip),%rax
mov    (%rax),%rdi
lea    0xd58(%rip),%rsi
lea    -0x24(%rbp),%rdx
call   10d0 <sscanf@plt>
cmp    $0x1,%eax
je     139f <main+0x1bf>
mov    0x2c5d(%rip),%rax
mov    (%rax),%edi
mov    0x2c74(%rip),%rax
mov    (%rax),%rdx
lea    0xd63(%rip),%rsi
call   10b0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14e7 <main+0x307>
jmp    13df <main+0x1ff>
movl   $0x0,-0x34(%rbp)
mov    0x2c46(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x24(%rbp)
jmp    13df <main+0x1ff>
mov    -0x10(%rbp),%rdi
call   10e0 <show_usage@plt>
movl   $0x0,-0x4(%rbp)
jmp    14e7 <main+0x307>
jmp    1249 <main+0x69>
mov    -0x18(%rbp),%rdi
call   10a0 <init_at24c256_i2c@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jge    1406 <main+0x226>
movl   $0xffffffff,-0x4(%rbp)
jmp    14e7 <main+0x307>
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
lea    0xd06(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
cmpl   $0x0,-0x34(%rbp)
jne    1462 <main+0x282>
mov    -0x3c(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x30(%rbp),%rcx
mov    -0x24(%rbp),%r8d
call   1040 <at24c256_write@plt>
mov    -0x30(%rbp),%rsi
mov    -0x24(%rbp),%edx
lea    0xd08(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x2710,%edi
call   1100 <usleep@plt>
jmp    14df <main+0x2ff>
cmpl   $0x1,-0x34(%rbp)
jne    14da <main+0x2fa>
mov    -0x24(%rbp),%edi
add    $0x1,%edi
call   10c0 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x24(%rbp),%edx
add    $0x1,%edx
xor    %esi,%esi
call   1080 <memset@plt>
mov    -0x3c(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x48(%rbp),%rcx
mov    -0x24(%rbp),%r8d
call   1060 <at24c256_read@plt>
mov    $0x2710,%edi
call   1100 <usleep@plt>
mov    -0x48(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x48(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x58(%rbp),%rsi
mov    %eax,%edx
lea    0xca8(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
jmp    14df <main+0x2ff>
mov    -0x3c(%rbp),%edi
call   1090 <close@plt>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
movl   $0x50,0x14(%rsp)
movl   $0x0,0x10(%rsp)
movl   $0x20,0xc(%rsp)
cmp    $0x1,%edi
jne    121b <main+0x3b>
mov    %rbx,%rdi
call   10e0 <show_usage@plt>
jmp    1410 <main+0x230>
mov    %edi,%ebp
lea    0xe43(%rip),%rdx
mov    %rbx,%rsi
call   10f0 <getopt@plt>
test   %eax,%eax
js     1313 <main+0x133>
mov    $0x1,%r13d
lea    0xe1b(%rip),%rcx
mov    %rcx,0x20(%rsp)
xor    %ecx,%ecx
mov    %rcx,0x18(%rsp)
lea    0xe13(%rip),%r12
lea    0xda5(%rip),%r15
mov    0x2d96(%rip),%r14
jmp    1285 <main+0xa5>
mov    (%r14),%rax
mov    %rax,0x20(%rsp)
nopl   0x0(%rax)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
call   10f0 <getopt@plt>
test   %eax,%eax
js     132c <main+0x14c>
add    $0xffffff9f,%eax
cmp    $0x16,%eax
ja     1270 <main+0x90>
movslq (%r15,%rax,4),%rax
add    %r15,%rax
jmp    *%rax
mov    (%r14),%rdi
lea    0xdd5(%rip),%rsi
lea    0x14(%rsp),%rdx
call   10d0 <sscanf@plt>
cmp    $0x1,%eax
je     1270 <main+0x90>
jmp    1421 <main+0x241>
mov    (%r14),%rdi
lea    0xdfc(%rip),%rsi
lea    0x10(%rsp),%rdx
call   10d0 <sscanf@plt>
cmp    $0x1,%eax
je     1270 <main+0x90>
jmp    1436 <main+0x256>
mov    (%r14),%rdi
lea    0xdde(%rip),%rsi
lea    0xc(%rsp),%rdx
call   10d0 <sscanf@plt>
mov    $0x1,%r13d
cmp    $0x1,%eax
je     1270 <main+0x90>
jmp    144b <main+0x26b>
mov    (%r14),%rdi
mov    %rdi,0x18(%rsp)
call   1050 <strlen@plt>
mov    %eax,0xc(%rsp)
xor    %r13d,%r13d
jmp    1270 <main+0x90>
lea    0xd42(%rip),%rax
mov    %rax,0x20(%rsp)
mov    $0x1,%r13d
xor    %eax,%eax
mov    %rax,0x18(%rsp)
mov    0x20(%rsp),%rbp
mov    %rbp,%rdi
call   10a0 <init_at24c256_i2c@plt>
test   %eax,%eax
js     13c7 <main+0x1e7>
mov    %eax,%ebx
mov    0x14(%rsp),%edx
mov    0x10(%rsp),%ecx
lea    0xdcb(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
test   %r13d,%r13d
je     13ce <main+0x1ee>
mov    0xc(%rsp),%edi
add    $0x1,%edi
call   10c0 <malloc@plt>
mov    %rax,%rbp
mov    0xc(%rsp),%edx
add    $0x1,%edx
mov    %rax,%rdi
xor    %esi,%esi
call   1080 <memset@plt>
mov    0x14(%rsp),%esi
mov    0x10(%rsp),%edx
mov    0xc(%rsp),%r8d
mov    %ebx,%edi
mov    %rbp,%rcx
call   1060 <at24c256_read@plt>
mov    $0x2710,%edi
call   1100 <usleep@plt>
mov    %rbp,%rdi
call   1050 <strlen@plt>
lea    0xdc1(%rip),%rdi
mov    %rbp,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
jmp    1409 <main+0x229>
mov    $0xffffffff,%eax
jmp    1412 <main+0x232>
mov    0x14(%rsp),%esi
mov    0x10(%rsp),%edx
mov    0xc(%rsp),%r8d
mov    %ebx,%edi
mov    0x18(%rsp),%rbp
mov    %rbp,%rcx
call   1040 <at24c256_write@plt>
mov    0xc(%rsp),%edx
lea    0xd5f(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x2710,%edi
call   1100 <usleep@plt>
mov    %ebx,%edi
call   1090 <close@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2bb0(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xc46(%rip),%rsi
jmp    145e <main+0x27e>
mov    0x2b9b(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xc74(%rip),%rsi
jmp    145e <main+0x27e>
mov    0x2b86(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xc93(%rip),%rsi
call   10b0 <fprintf@plt>
mov    $0xffffffff,%eax
jmp    1412 <main+0x232>

LLVM IR (-O0):
@.str = [11 x i8] c"/dev/i2c-1\00"
@.str.1 = [14 x i8] c"d:a:o:r:w:n:h\00"
@optarg = global i8* null
@.str.2 = [5 x i8] c"0x%x\00"
@stderr = global i32 0
@.str.3 = [64 x i8] c"Cannot parse '%s' as i2c slave device address, example: '0x50'\0A\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [52 x i8] c"Cannot parse '%s' as address offset, example: '32'\0A\00"
@.str.6 = [44 x i8] c"Cannot parse '%s' as length, example: '17'\0A\00"
@.str.7 = [55 x i8] c"i2c device file:%s\0Aslave_address:0x%X\0AR/W offset:0x%X\0A\00"
@.str.8 = [30 x i8] c"try to write: %s (%d bytes)!\0A\00"
@.str.9 = [42 x i8] c"read from at24c256 eeprom: %s (%d bytes)\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %6
store i32 80, i32* %7
store i32 0, i32* %8
store i32 32, i32* %9
store i8* null, i8** %10
store i32 1, i32* %11
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %20
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = call i32 @show_usage(i8** %18)
store i32 0, i32* %3
br label %118
20: ; preds = %2
br label %21
21: ; preds = %64, %20
%22 = load i32, i32* %4
%23 = load i8**, i8*** %5
%24 = call i32 @getopt(i32 %22, i8** %23, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
store i32 %24, i32* %12
%25 = icmp sge i32 %24, 0
br i1 %25, label %26, label %65
26: ; preds = %21
%27 = load i32, i32* %12
switch i32 %27, label %64 [
i32 100, label %28
i32 97, label %30
i32 111, label %39
i32 114, label %48
i32 119, label %57
i32 104, label %61
]
28: ; preds = %26
%29 = load i8*, i8** @optarg
store i8* %29, i8** %6
br label %64
30: ; preds = %26
%31 = load i8*, i8** @optarg
%32 = call i32 @sscanf(i8* %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32* %7)
%33 = icmp ne i32 %32, 1
br i1 %33, label %34, label %38
34: ; preds = %30
%35 = load i32, i32* @stderr
%36 = load i8*, i8** @optarg
%37 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.3, i64 0, i64 0), i8* %36)
store i32 -1, i32* %3
br label %118
38: ; preds = %30
br label %64
39: ; preds = %26
%40 = load i8*, i8** @optarg
%41 = call i32 @sscanf(i8* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %8)
%42 = icmp ne i32 %41, 1
br i1 %42, label %43, label %47
43: ; preds = %39
%44 = load i32, i32* @stderr
%45 = load i8*, i8** @optarg
%46 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0), i8* %45)
store i32 -1, i32* %3
br label %118
47: ; preds = %39
br label %64
48: ; preds = %26
store i32 1, i32* %11
%49 = load i8*, i8** @optarg
%50 = call i32 @sscanf(i8* %49, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %9)
%51 = icmp ne i32 %50, 1
br i1 %51, label %52, label %56
52: ; preds = %48
%53 = load i32, i32* @stderr
%54 = load i8*, i8** @optarg
%55 = call i32 @fprintf(i32 %53, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), i8* %54)
store i32 -1, i32* %3
br label %118
56: ; preds = %48
br label %64
57: ; preds = %26
store i32 0, i32* %11
%58 = load i8*, i8** @optarg
store i8* %58, i8** %10
%59 = load i8*, i8** %10
%60 = call i32 @strlen(i8* %59)
store i32 %60, i32* %9
br label %64
61: ; preds = %26
%62 = load i8**, i8*** %5
%63 = call i32 @show_usage(i8** %62)
store i32 0, i32* %3
br label %118
64: ; preds = %26, %57, %56, %47, %38, %28
br label %21
65: ; preds = %21
%66 = load i8*, i8** %6
%67 = call i32 @init_at24c256_i2c(i8* %66)
store i32 %67, i32* %13
%68 = load i32, i32* %13
%69 = icmp slt i32 %68, 0
br i1 %69, label %70, label %71
70: ; preds = %65
store i32 -1, i32* %3
br label %118
71: ; preds = %65
%72 = load i8*, i8** %6
%73 = load i32, i32* %7
%74 = load i32, i32* %8
%75 = call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.7, i64 0, i64 0), i8* %72, i32 %73, i32 %74)
%76 = load i32, i32* %11
%77 = icmp eq i32 %76, 0
br i1 %77, label %78, label %89
78: ; preds = %71
%79 = load i32, i32* %13
%80 = load i32, i32* %7
%81 = load i32, i32* %8
%82 = load i8*, i8** %10
%83 = load i32, i32* %9
%84 = call i32 @at24c256_write(i32 %79, i32 %80, i32 %81, i8* %82, i32 %83)
%85 = load i8*, i8** %10
%86 = load i32, i32* %9
%87 = call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0), i8* %85, i32 %86)
%88 = call i32 @usleep(i32 10000)
br label %115
89: ; preds = %71
%90 = load i32, i32* %11
%91 = icmp eq i32 %90, 1
br i1 %91, label %92, label %114
92: ; preds = %89
%93 = load i32, i32* %9
%94 = add nsw i32 %93, 1
%95 = call i64 @malloc(i32 %94)
%96 = inttoptr i64 %95 to i8*
store i8* %96, i8** %14
%97 = load i8*, i8** %14
%98 = load i32, i32* %9
%99 = add nsw i32 %98, 1
%100 = call i32 @memset(i8* %97, i32 0, i32 %99)
%101 = load i32, i32* %13
%102 = load i32, i32* %7
%103 = load i32, i32* %8
%104 = load i8*, i8** %14
%105 = load i32, i32* %9
%106 = call i32 @at24c256_read(i32 %101, i32 %102, i32 %103, i8* %104, i32 %105)
%107 = call i32 @usleep(i32 10000)
%108 = load i8*, i8** %14
%109 = load i8*, i8** %14
%110 = call i32 @strlen(i8* %109)
%111 = call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.9, i64 0, i64 0), i8* %108, i32 %110)
%112 = load i8*, i8** %14
%113 = call i32 @free(i8* %112)
br label %114
114: ; preds = %92, %89
br label %115
115: ; preds = %114, %78
%116 = load i32, i32* %13
%117 = call i32 @close(i32 %116)
br label %118
118: ; preds = %115, %70, %61, %52, %43, %34, %17
%119 = load i32, i32* %3
ret i32 %119
}

LLVM IR (-O2):
@.str = [11 x i8] c"/dev/i2c-1\00"
@.str.1 = [14 x i8] c"d:a:o:r:w:n:h\00"
@optarg = global i8* null
@.str.2 = [5 x i8] c"0x%x\00"
@stderr = global i32 0
@.str.3 = [64 x i8] c"Cannot parse '%s' as i2c slave device address, example: '0x50'\0A\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [52 x i8] c"Cannot parse '%s' as address offset, example: '32'\0A\00"
@.str.6 = [44 x i8] c"Cannot parse '%s' as length, example: '17'\0A\00"
@.str.7 = [55 x i8] c"i2c device file:%s\0Aslave_address:0x%X\0AR/W offset:0x%X\0A\00"
@.str.8 = [30 x i8] c"try to write: %s (%d bytes)!\0A\00"
@.str.9 = [42 x i8] c"read from at24c256 eeprom: %s (%d bytes)\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %3 to i8*
store i32 80, i32* %3
%7 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%8 = bitcast i32* %5 to i8*
store i32 32, i32* %5
%9 = icmp eq i32 %0, 1
br i1 %9, label %13, label %10
10: ; preds = %2
%11 = call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp sgt i32 %11, -1
br i1 %12, label %15, label %57
13: ; preds = %2
%14 = tail call i32 @show_usage(i8** %1)
br label %94
15: ; preds = %10, %51
%16 = phi i32 [ %55, %51 ], [ %11, %10 ]
%17 = phi i8* [ %54, %51 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), %10 ]
%18 = phi i8* [ %53, %51 ], [ null, %10 ]
%19 = phi i32 [ %52, %51 ], [ 1, %10 ]
switch i32 %16, label %51 [
i32 100, label %20
i32 97, label %22
i32 111, label %30
i32 114, label %38
i32 119, label %46
i32 104, label %49
]
20: ; preds = %15
%21 = load i8*, i8** @optarg
br label %51
22: ; preds = %15
%23 = load i8*, i8** @optarg
%24 = call i32 @sscanf(i8* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%25 = icmp eq i32 %24, 1
br i1 %25, label %51, label %26
26: ; preds = %22
%27 = load i32, i32* @stderr
%28 = load i8*, i8** @optarg
%29 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.3, i64 0, i64 0), i8* %28)
br label %94
30: ; preds = %15
%31 = load i8*, i8** @optarg
%32 = call i32 @sscanf(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %4)
%33 = icmp eq i32 %32, 1
br i1 %33, label %51, label %34
34: ; preds = %30
%35 = load i32, i32* @stderr
%36 = load i8*, i8** @optarg
%37 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0), i8* %36)
br label %94
38: ; preds = %15
%39 = load i8*, i8** @optarg
%40 = call i32 @sscanf(i8* %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %5)
%41 = icmp eq i32 %40, 1
br i1 %41, label %51, label %42
42: ; preds = %38
%43 = load i32, i32* @stderr
%44 = load i8*, i8** @optarg
%45 = call i32 @fprintf(i32 %43, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), i8* %44)
br label %94
46: ; preds = %15
%47 = load i8*, i8** @optarg
%48 = call i32 @strlen(i8* %47)
store i32 %48, i32* %5
br label %51
49: ; preds = %15
%50 = call i32 @show_usage(i8** %1)
br label %94
51: ; preds = %38, %30, %22, %15, %46, %20
%52 = phi i32 [ %19, %15 ], [ 0, %46 ], [ 1, %38 ], [ %19, %30 ], [ %19, %22 ], [ %19, %20 ]
%53 = phi i8* [ %18, %15 ], [ %47, %46 ], [ %18, %38 ], [ %18, %30 ], [ %18, %22 ], [ %18, %20 ]
%54 = phi i8* [ %17, %15 ], [ %17, %46 ], [ %17, %38 ], [ %17, %30 ], [ %17, %22 ], [ %21, %20 ]
%55 = call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%56 = icmp sgt i32 %55, -1
br i1 %56, label %15, label %57
57: ; preds = %51, %10
%58 = phi i32 [ 1, %10 ], [ %52, %51 ]
%59 = phi i8* [ null, %10 ], [ %53, %51 ]
%60 = phi i8* [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), %10 ], [ %54, %51 ]
%61 = call i32 @init_at24c256_i2c(i8* %60)
%62 = icmp slt i32 %61, 0
br i1 %62, label %94, label %63
63: ; preds = %57
%64 = load i32, i32* %3
%65 = load i32, i32* %4
%66 = call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.7, i64 0, i64 0), i8* %60, i32 %64, i32 %65)
%67 = icmp eq i32 %58, 0
br i1 %67, label %68, label %76
68: ; preds = %63
%69 = load i32, i32* %3
%70 = load i32, i32* %4
%71 = load i32, i32* %5
%72 = call i32 @at24c256_write(i32 %61, i32 %69, i32 %70, i8* %59, i32 %71)
%73 = load i32, i32* %5
%74 = call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0), i8* %59, i32 %73)
%75 = call i32 @usleep(i32 10000)
br label %92
76: ; preds = %63
%77 = load i32, i32* %5
%78 = add nsw i32 %77, 1
%79 = call i64 @malloc(i32 %78)
%80 = inttoptr i64 %79 to i8*
%81 = load i32, i32* %5
%82 = add nsw i32 %81, 1
%83 = call i32 @memset(i8* %80, i32 0, i32 %82)
%84 = load i32, i32* %3
%85 = load i32, i32* %4
%86 = load i32, i32* %5
%87 = call i32 @at24c256_read(i32 %61, i32 %84, i32 %85, i8* %80, i32 %86)
%88 = call i32 @usleep(i32 10000)
%89 = call i32 @strlen(i8* %80)
%90 = call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.9, i64 0, i64 0), i8* %80, i32 %89)
%91 = call i32 @free(i8* %80)
br label %92
92: ; preds = %76, %68
%93 = call i32 @close(i32 %61)
br label %94
94: ; preds = %26, %34, %42, %49, %57, %92, %13
%95 = phi i32 [ 0, %13 ], [ 0, %49 ], [ -1, %42 ], [ -1, %34 ], [ -1, %26 ], [ 0, %92 ], [ -1, %57 ]
ret i32 %95
}