#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*/ clean_buffer_ut804(unsigned char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ display_buffer_ut804(unsigned char *);
int /*<<< orphan*/ display_gnu();
int /*<<< orphan*/ display_usage();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int getopt(int, char **, char *);
int /*<<< orphan*/ isprint(char);
int open_port_ut804(char *);
char *optarg;
scalar_t__ opterr;
char optopt;
int /*<<< orphan*/ printf(char *, ...);
int read(int, unsigned char *, int);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  char *dvalue = NULL;
  int c, j;
  int multimeter_fd;
  unsigned char buffer_ut804[11];
  int continue_main_loop;
  int verbose_flag = 0;
  display_gnu();
  opterr = 0;
  while ((c = getopt(argc, argv, "hd:v")) != -1) {
    switch (c) {
    case 'd':
      dvalue = optarg;
      break;
    case 'v':
      verbose_flag = 1;
      break;
    case '?':
      if (optopt == 'd')
        fprintf(stderr, "Option -%c requires an argument. Try -h for help.\n",
                optopt);
      else if (isprint(optopt))
        fprintf(stderr, "Unknown option `-%c'. Try -h for help.\n", optopt);
      else
        fprintf(stderr, "Unknown option character `\\x%x'. Try -h for help.\n",
                optopt);
      return 1;
    case 'h':
      display_usage();
      return 0;
    default:
      display_usage();
      return -1;
    }
  }
  multimeter_fd = open_port_ut804(dvalue);
  if (multimeter_fd == (-1)) {
    printf("\t\t ---> check connection to the device\n\n");
    return -1;
  }
  continue_main_loop = 1;
  while (continue_main_loop) {
    j = read(multimeter_fd, buffer_ut804, 11);
    if (j < 0) {
      fputs("read() from multimeter_fd failed!\n", stderr);
      continue_main_loop = 0;
    }
    if (verbose_flag == 1) {
      printf("raw data: ");
      printf("%2X|", buffer_ut804[0]);
      printf("%2X|", buffer_ut804[1]);
      printf("%2X|", buffer_ut804[2]);
      printf("%2X|", buffer_ut804[3]);
      printf("%2X|", buffer_ut804[4]);
      printf("%2X|", buffer_ut804[5]);
      printf("****** %2X|", buffer_ut804[6]);
      printf("%2X|", buffer_ut804[7]);
      printf("%2X|", buffer_ut804[8]);
      printf("%2X|", buffer_ut804[9]);
      printf("%2X|", buffer_ut804[10]);
      printf(" \n");
    }
    if (!(buffer_ut804[7] == 0 && buffer_ut804[8] == 0 &&
          buffer_ut804[9] == 0 && buffer_ut804[10] == 0)) {
      display_buffer_ut804(buffer_ut804);
      printf("\n");
      clean_buffer_ut804(buffer_ut804);
    }
  }
  close(multimeter_fd);
  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)
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x38(%rbp)
mov    $0x0,%al
call   10c0 <display_gnu@plt>
mov    0x2dd5(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xdf8(%rip),%rdx
call   10e0 <getopt@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
je     134d <main+0x18d>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
sub    $0x3f,%eax
je     127f <main+0xbf>
jmp    122d <main+0x6d>
mov    -0x3c(%rbp),%eax
sub    $0x64,%eax
je     1260 <main+0xa0>
jmp    123e <main+0x7e>
mov    -0x3c(%rbp),%eax
sub    $0x68,%eax
je     1322 <main+0x162>
jmp    124f <main+0x8f>
mov    -0x3c(%rbp),%eax
sub    $0x76,%eax
je     1273 <main+0xb3>
jmp    1335 <main+0x175>
mov    0x2d91(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    1348 <main+0x188>
movl   $0x1,-0x38(%rbp)
jmp    1348 <main+0x188>
mov    0x2d5a(%rip),%rax
movsbl (%rax),%eax
cmp    $0x64,%eax
jne    12b6 <main+0xf6>
mov    0x2d37(%rip),%rax
mov    (%rax),%edi
lea    0xd63(%rip),%rsi
mov    0x2d37(%rip),%rax
movsbl (%rax),%edx
call   10a0 <fprintf@plt>
jmp    1316 <main+0x156>
mov    0x2d23(%rip),%rax
movsbl (%rax),%edi
call   10d0 <isprint@plt>
cmp    $0x0,%eax
je     12f2 <main+0x132>
mov    0x2cfb(%rip),%rax
mov    (%rax),%edi
lea    0xd5a(%rip),%rsi
mov    0x2cfb(%rip),%rax
movsbl (%rax),%edx
call   10a0 <fprintf@plt>
jmp    1311 <main+0x151>
mov    0x2cd7(%rip),%rax
mov    (%rax),%edi
lea    0xd5e(%rip),%rsi
mov    0x2cd7(%rip),%rax
movsbl (%rax),%edx
call   10a0 <fprintf@plt>
jmp    1316 <main+0x156>
movl   $0x1,-0x4(%rbp)
jmp    151c <main+0x35c>
mov    $0x0,%al
call   1050 <display_usage@plt>
movl   $0x0,-0x4(%rbp)
jmp    151c <main+0x35c>
mov    $0x0,%al
call   1050 <display_usage@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    151c <main+0x35c>
jmp    11fa <main+0x3a>
mov    -0x18(%rbp),%rdi
call   1070 <open_port_ut804@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    137d <main+0x1bd>
lea    0xd29(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    151c <main+0x35c>
movl   $0x1,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     150d <main+0x34d>
mov    -0x24(%rbp),%edi
lea    -0x2f(%rbp),%rsi
mov    $0xb,%edx
call   1090 <read@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    13c8 <main+0x208>
mov    0x2c1d(%rip),%rax
mov    (%rax),%esi
lea    0xd00(%rip),%rdi
call   1060 <fputs@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0x1,-0x38(%rbp)
jne    14b4 <main+0x2f4>
lea    0xd06(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movzbl -0x2f(%rbp),%esi
lea    0xd06(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movzbl -0x2e(%rbp),%esi
lea    0xcf4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movzbl -0x2d(%rbp),%esi
lea    0xce2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movzbl -0x2c(%rbp),%esi
lea    0xcd0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movzbl -0x2b(%rbp),%esi
lea    0xcbe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movzbl -0x2a(%rbp),%esi
lea    0xcac(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movzbl -0x29(%rbp),%esi
lea    0xc93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movzbl -0x28(%rbp),%esi
lea    0xc88(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movzbl -0x27(%rbp),%esi
lea    0xc76(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movzbl -0x26(%rbp),%esi
lea    0xc64(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movzbl -0x25(%rbp),%esi
lea    0xc52(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xc49(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movzbl -0x28(%rbp),%eax
cmp    $0x0,%eax
jne    14e8 <main+0x328>
movzbl -0x27(%rbp),%eax
cmp    $0x0,%eax
jne    14e8 <main+0x328>
movzbl -0x26(%rbp),%eax
cmp    $0x0,%eax
jne    14e8 <main+0x328>
movzbl -0x25(%rbp),%eax
cmp    $0x0,%eax
je     1508 <main+0x348>
lea    -0x2f(%rbp),%rdi
call   10b0 <display_buffer_ut804@plt>
lea    0xbc2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x2f(%rbp),%rdi
call   1030 <clean_buffer_ut804@plt>
jmp    1384 <main+0x1c4>
mov    -0x24(%rbp),%edi
call   1080 <close@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
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %r14d,%r14d
xor    %eax,%eax
call   10e0 <display_gnu@plt>
mov    0x2dc4(%rip),%rax
movq   $0x0,(%rax)
lea    0xdee(%rip),%r15
mov    0x2ddf(%rip),%r12
xor    %r13d,%r13d
mov    %r13d,%ecx
nop
mov    %ecx,%r13d
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1100 <getopt@plt>
mov    $0x1,%ecx
cmp    $0x76,%eax
je     1220 <main+0x40>
cmp    $0x63,%eax
jle    1253 <main+0x73>
cmp    $0x68,%eax
je     128c <main+0xac>
cmp    $0x64,%eax
jne    1411 <main+0x231>
mov    (%r12),%r14
jmp    121c <main+0x3c>
cmp    $0xffffffff,%eax
je     129a <main+0xba>
cmp    $0x3f,%eax
jne    1411 <main+0x231>
mov    0x2d78(%rip),%rbx
mov    (%rbx),%al
cmp    $0x64,%al
jne    142b <main+0x24b>
mov    0x2d57(%rip),%rax
mov    (%rax),%edi
lea    0xd83(%rip),%rsi
mov    $0x64,%edx
jmp    1468 <main+0x288>
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <display_usage@plt>
jmp    1472 <main+0x292>
mov    %r14,%rdi
call   1090 <open_port_ut804@plt>
cmp    $0xffffffff,%eax
je     144e <main+0x26e>
mov    %eax,%r12d
lea    0xd(%rsp),%rbx
lea    0xe0e(%rip),%rbp
lea    0xdfe(%rip),%r14
jmp    12d9 <main+0xf9>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
test   %r15d,%r15d
js     141f <main+0x23f>
mov    %r12d,%edi
mov    %rbx,%rsi
mov    $0xb,%edx
call   10b0 <read@plt>
mov    %eax,%r15d
test   %eax,%eax
js     13f0 <main+0x210>
cmp    $0x1,%r13d
jne    13bd <main+0x1dd>
lea    0xdb1(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movzbl 0xd(%rsp),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movzbl 0xe(%rsp),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movzbl 0xf(%rsp),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movzbl 0x10(%rsp),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movzbl 0x11(%rsp),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movzbl 0x12(%rsp),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movzbl 0x13(%rsp),%esi
lea    0xd4f(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movzbl 0x14(%rsp),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movzbl 0x15(%rsp),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movzbl 0x16(%rsp),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movzbl 0x17(%rsp),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
call   1050 <puts@plt>
movd   0x14(%rsp),%xmm0
movd   %xmm0,%eax
test   %eax,%eax
je     12d0 <main+0xf0>
mov    %rbx,%rdi
call   10d0 <display_buffer_ut804@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1040 <clean_buffer_ut804@plt>
jmp    12d0 <main+0xf0>
xchg   %ax,%ax
mov    0x2bd9(%rip),%rax
mov    (%rax),%esi
lea    0xc93(%rip),%rdi
call   1080 <fputs@plt>
cmp    $0x1,%r13d
je     12fe <main+0x11e>
jmp    13bd <main+0x1dd>
xor    %eax,%eax
call   1070 <display_usage@plt>
mov    $0xffffffff,%ebx
jmp    1472 <main+0x292>
mov    %r12d,%edi
call   10a0 <close@plt>
xor    %ebx,%ebx
jmp    1472 <main+0x292>
movsbl %al,%edi
call   10f0 <isprint@plt>
mov    0x2b96(%rip),%rcx
mov    (%rcx),%edi
mov    (%rbx),%cl
movsbl %cl,%edx
test   %eax,%eax
je     1461 <main+0x281>
lea    0xbec(%rip),%rsi
jmp    1468 <main+0x288>
lea    0xc78(%rip),%rdi
call   1050 <puts@plt>
mov    $0xffffffff,%ebx
jmp    1472 <main+0x292>
lea    0xbf8(%rip),%rsi
call   10c0 <fprintf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@opterr = global i64 0
@.str = [5 x i8] c"hd:v\00"
@optarg = global i8* null
@optopt = global i8 0
@stderr = global i32 0
@.str.1 = [51 x i8] c"Option -%c requires an argument. Try -h for help.\0A\00"
@.str.2 = [40 x i8] c"Unknown option `-%c'. Try -h for help.\0A\00"
@.str.3 = [51 x i8] c"Unknown option character `\\x%x'. Try -h for help.\0A\00"
@.str.4 = [41 x i8] c"\09\09 ---> check connection to the device\0A\0A\00"
@.str.5 = [35 x i8] c"read() from multimeter_fd failed!\0A\00"
@.str.6 = [11 x i8] c"raw data: \00"
@.str.7 = [5 x i8] c"%2X|\00"
@.str.8 = [12 x i8] c"****** %2X|\00"
@.str.9 = [3 x i8] c" \0A\00"
@.str.10 = [2 x i8] c"\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 [11 x i8]
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
store i32 0, i32* %12
%13 = call i32 (...) @display_gnu()
store i64 0, i64* @opterr
br label %14
14: ; preds = %50, %2
%15 = load i32, i32* %4
%16 = load i8**, i8*** %5
%17 = call i32 @getopt(i32 %15, i8** %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %17, i32* %7
%18 = icmp ne i32 %17, -1
br i1 %18, label %19, label %51
19: ; preds = %14
%20 = load i32, i32* %7
switch i32 %20, label %48 [
i32 100, label %21
i32 118, label %23
i32 63, label %24
i32 104, label %46
]
21: ; preds = %19
%22 = load i8*, i8** @optarg
store i8* %22, i8** %6
br label %50
23: ; preds = %19
store i32 1, i32* %12
br label %50
24: ; preds = %19
%25 = load i8, i8* @optopt
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 100
br i1 %27, label %28, label %32
28: ; preds = %24
%29 = load i32, i32* @stderr
%30 = load i8, i8* @optopt
%31 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i8 signext %30)
br label %45
32: ; preds = %24
%33 = load i8, i8* @optopt
%34 = call i32 @isprint(i8 signext %33)
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %40
36: ; preds = %32
%37 = load i32, i32* @stderr
%38 = load i8, i8* @optopt
%39 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i8 signext %38)
br label %44
40: ; preds = %32
%41 = load i32, i32* @stderr
%42 = load i8, i8* @optopt
%43 = call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0), i8 signext %42)
br label %44
44: ; preds = %40, %36
br label %45
45: ; preds = %44, %28
store i32 1, i32* %3
br label %151
46: ; preds = %19
%47 = call i32 (...) @display_usage()
store i32 0, i32* %3
br label %151
48: ; preds = %19
%49 = call i32 (...) @display_usage()
store i32 -1, i32* %3
br label %151
50: ; preds = %23, %21
br label %14
51: ; preds = %14
%52 = load i8*, i8** %6
%53 = call i32 @open_port_ut804(i8* %52)
store i32 %53, i32* %9
%54 = load i32, i32* %9
%55 = icmp eq i32 %54, -1
br i1 %55, label %56, label %58
56: ; preds = %51
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %3
br label %151
58: ; preds = %51
store i32 1, i32* %11
br label %59
59: ; preds = %147, %58
%60 = load i32, i32* %11
%61 = icmp ne i32 %60, 0
br i1 %61, label %62, label %148
62: ; preds = %59
%63 = load i32, i32* %9
%64 = getelementptr inbounds [11 x i8], [11 x i8]* %10, i64 0, i64 0
%65 = call i32 @read(i32 %63, i8* %64, i32 11)
store i32 %65, i32* %8
%66 = load i32, i32* %8
%67 = icmp slt i32 %66, 0
br i1 %67, label %68, label %71
68: ; preds = %62
%69 = load i32, i32* @stderr
%70 = call i32 @fputs(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0), i32 %69)
store i32 0, i32* %11
br label %71
71: ; preds = %68, %62
%72 = load i32, i32* %12
%73 = icmp eq i32 %72, 1
br i1 %73, label %74, label %121
74: ; preds = %71
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
%76 = getelementptr inbounds [11 x i8], [11 x i8]* %10, i64 0, i64 0
%77 = load i8, i8* %76
%78 = zext i8 %77 to i32
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %78)
%80 = getelementptr inbounds [11 x i8], [11 x i8]* %10, i64 0, i64 1
%81 = load i8, i8* %80
%82 = zext i8 %81 to i32
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %82)
%84 = getelementptr inbounds [11 x i8], [11 x i8]* %10, i64 0, i64 2
%85 = load i8, i8* %84
%86 = zext i8 %85 to i32
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %86)
%88 = getelementptr inbounds [11 x i8], [11 x i8]* %10, i64 0, i64 3
%89 = load i8, i8* %88
%90 = zext i8 %89 to i32
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %90)
%92 = getelementptr inbounds [11 x i8], [11 x i8]* %10, i64 0, i64 4
%93 = load i8, i8* %92
%94 = zext i8 %93 to i32
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %94)
%96 = getelementptr inbounds [11 x i8], [11 x i8]* %10, i64 0, i64 5
%97 = load i8, i8* %96
%98 = zext i8 %97 to i32
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %98)
%100 = getelementptr inbounds [11 x i8], [11 x i8]* %10, i64 0, i64 6
%101 = load i8, i8* %100
%102 = zext i8 %101 to i32
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i32 %102)
%104 = getelementptr inbounds [11 x i8], [11 x i8]* %10, i64 0, i64 7
%105 = load i8, i8* %104
%106 = zext i8 %105 to i32
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %106)
%108 = getelementptr inbounds [11 x i8], [11 x i8]* %10, i64 0, i64 8
%109 = load i8, i8* %108
%110 = zext i8 %109 to i32
%111 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %110)
%112 = getelementptr inbounds [11 x i8], [11 x i8]* %10, i64 0, i64 9
%113 = load i8, i8* %112
%114 = zext i8 %113 to i32
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %114)
%116 = getelementptr inbounds [11 x i8], [11 x i8]* %10, i64 0, i64 10
%117 = load i8, i8* %116
%118 = zext i8 %117 to i32
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %118)
%120 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
br label %121
121: ; preds = %74, %71
%122 = getelementptr inbounds [11 x i8], [11 x i8]* %10, i64 0, i64 7
%123 = load i8, i8* %122
%124 = zext i8 %123 to i32
%125 = icmp eq i32 %124, 0
br i1 %125, label %126, label %141
126: ; preds = %121
%127 = getelementptr inbounds [11 x i8], [11 x i8]* %10, i64 0, i64 8
%128 = load i8, i8* %127
%129 = zext i8 %128 to i32
%130 = icmp eq i32 %129, 0
br i1 %130, label %131, label %141
131: ; preds = %126
%132 = getelementptr inbounds [11 x i8], [11 x i8]* %10, i64 0, i64 9
%133 = load i8, i8* %132
%134 = zext i8 %133 to i32
%135 = icmp eq i32 %134, 0
br i1 %135, label %136, label %141
136: ; preds = %131
%137 = getelementptr inbounds [11 x i8], [11 x i8]* %10, i64 0, i64 10
%138 = load i8, i8* %137
%139 = zext i8 %138 to i32
%140 = icmp eq i32 %139, 0
br i1 %140, label %147, label %141
141: ; preds = %136, %131, %126, %121
%142 = getelementptr inbounds [11 x i8], [11 x i8]* %10, i64 0, i64 0
%143 = call i32 @display_buffer_ut804(i8* %142)
%144 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%145 = getelementptr inbounds [11 x i8], [11 x i8]* %10, i64 0, i64 0
%146 = call i32 @clean_buffer_ut804(i8* %145)
br label %147
147: ; preds = %141, %136
br label %59
148: ; preds = %59
%149 = load i32, i32* %9
%150 = call i32 @close(i32 %149)
store i32 0, i32* %3
br label %151
151: ; preds = %148, %56, %48, %46, %45
%152 = load i32, i32* %3
ret i32 %152
}

LLVM IR (-O2):
@opterr = global i64 0
@.str = [5 x i8] c"hd:v\00"
@optarg = global i8* null
@optopt = global i8 0
@stderr = global i32 0
@.str.1 = [51 x i8] c"Option -%c requires an argument. Try -h for help.\0A\00"
@.str.2 = [40 x i8] c"Unknown option `-%c'. Try -h for help.\0A\00"
@.str.3 = [51 x i8] c"Unknown option character `\\x%x'. Try -h for help.\0A\00"
@.str.5 = [35 x i8] c"read() from multimeter_fd failed!\0A\00"
@.str.6 = [11 x i8] c"raw data: \00"
@.str.7 = [5 x i8] c"%2X|\00"
@.str.8 = [12 x i8] c"****** %2X|\00"
@str = [2 x i8] c" \00"
@str.11 = [40 x i8] c"\09\09 ---> check connection to the device\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [11 x i8]
%4 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
%5 = tail call i32 (...) @display_gnu()
store i64 0, i64* @opterr
br label %6
6: ; preds = %12, %2
%7 = phi i8* [ %13, %12 ], [ null, %2 ]
%8 = phi i32 [ %10, %12 ], [ 0, %2 ]
br label %9
9: ; preds = %6, %9
%10 = phi i32 [ 1, %9 ], [ %8, %6 ]
%11 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
switch i32 %11, label %31 [
i32 -1, label %33
i32 100, label %12
i32 118, label %9
i32 63, label %14
i32 104, label %29
]
12: ; preds = %9
%13 = load i8*, i8** @optarg
br label %6
14: ; preds = %9
%15 = load i8, i8* @optopt
%16 = icmp eq i8 %15, 100
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i32, i32* @stderr
%19 = tail call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i8 signext 100)
br label %106
20: ; preds = %14
%21 = tail call i32 @isprint(i8 signext %15)
%22 = icmp eq i32 %21, 0
%23 = load i32, i32* @stderr
%24 = load i8, i8* @optopt
br i1 %22, label %27, label %25
25: ; preds = %20
%26 = tail call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i8 signext %24)
br label %106
27: ; preds = %20
%28 = tail call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0), i8 signext %24)
br label %106
29: ; preds = %9
%30 = tail call i32 (...) @display_usage()
br label %106
31: ; preds = %9
%32 = tail call i32 (...) @display_usage()
br label %106
33: ; preds = %9
%34 = tail call i32 @open_port_ut804(i8* %7)
%35 = icmp eq i32 %34, -1
br i1 %35, label %49, label %36
36: ; preds = %33
%37 = icmp eq i32 %10, 1
%38 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 1
%39 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 2
%40 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 3
%41 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 4
%42 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 5
%43 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 6
%44 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 7
%45 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 8
%46 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 9
%47 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 10
%48 = bitcast i8* %44 to <4 x i8>*
br label %51
49: ; preds = %33
%50 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.11, i64 0, i64 0))
br label %106
51: ; preds = %36, %103
%52 = call i32 @read(i32 %34, i8* %4, i32 11)
%53 = icmp slt i32 %52, 0
br i1 %53, label %54, label %57
54: ; preds = %51
%55 = load i32, i32* @stderr
%56 = call i32 @fputs(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0), i32 %55)
br label %57
57: ; preds = %54, %51
br i1 %37, label %58, label %94
58: ; preds = %57
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
%60 = load i8, i8* %4
%61 = zext i8 %60 to i32
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %61)
%63 = load i8, i8* %38
%64 = zext i8 %63 to i32
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %64)
%66 = load i8, i8* %39
%67 = zext i8 %66 to i32
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %67)
%69 = load i8, i8* %40
%70 = zext i8 %69 to i32
%71 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %70)
%72 = load i8, i8* %41
%73 = zext i8 %72 to i32
%74 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %73)
%75 = load i8, i8* %42
%76 = zext i8 %75 to i32
%77 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %76)
%78 = load i8, i8* %43
%79 = zext i8 %78 to i32
%80 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i32 %79)
%81 = load i8, i8* %44
%82 = zext i8 %81 to i32
%83 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %82)
%84 = load i8, i8* %45
%85 = zext i8 %84 to i32
%86 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %85)
%87 = load i8, i8* %46
%88 = zext i8 %87 to i32
%89 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %88)
%90 = load i8, i8* %47
%91 = zext i8 %90 to i32
%92 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %91)
%93 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
br label %94
94: ; preds = %58, %57
%95 = load <4 x i8>, <4 x i8>* %48
%96 = freeze <4 x i8> %95
%97 = bitcast <4 x i8> %96 to i32
%98 = icmp eq i32 %97, 0
br i1 %98, label %103, label %99
99: ; preds = %94
%100 = call i32 @display_buffer_ut804(i8* %4)
%101 = call i32 @putchar(i32 10)
%102 = call i32 @clean_buffer_ut804(i8* %4)
br label %103
103: ; preds = %94, %99
br i1 %53, label %104, label %51
104: ; preds = %103
%105 = call i32 @close(i32 %34)
br label %106
106: ; preds = %17, %27, %25, %104, %49, %31, %29
%107 = phi i32 [ -1, %31 ], [ 0, %29 ], [ -1, %49 ], [ 0, %104 ], [ 1, %25 ], [ 1, %27 ], [ 1, %17 ]
ret i32 %107
}