#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*/ adc_test1();
int /*<<< orphan*/ adc_test2();
int /*<<< orphan*/ adc_test3();
int /*<<< orphan*/ calibrate();
int /*<<< orphan*/ measure_rint();
scalar_t__ my_cmp(char *, char *);
int my_strlen(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ relay_closed();
int /*<<< orphan*/ relay_open();
int /*<<< orphan*/ serial_getl(char *);
void serial_cmd(void) {
  char buf[80];
  for (;;) {
    printf("Command: ");
    serial_getl(buf);
    if (my_cmp(buf, "rc")) {
      relay_closed();
    } else if (my_cmp(buf, "ro")) {
      relay_open();
    } else if (my_cmp(buf, "ri")) {
      measure_rint();
    } else if (my_cmp(buf, "t1")) {
      adc_test1();
    } else if (my_cmp(buf, "t2")) {
      adc_test2();
    } else if (my_cmp(buf, "t3")) {
      adc_test3();
    } else if (my_cmp(buf, "cal")) {
      calibrate();
    } else if (my_cmp(buf, "check")) {
      printf("OK\n");
    } else if (my_cmp(buf, "quit")) {
      printf("Done\n");
      break;
    } else {
      int len = my_strlen(buf);
      printf("Got: %s (%d)\n", buf, len);
    }
  }
}


x86 assembly (clang, -O0):
<serial_cmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x50(%rbp),%rdi
call   1060 <serial_getl@plt>
lea    -0x50(%rbp),%rdi
lea    0xe30(%rip),%rsi
call   10c0 <my_cmp@plt>
cmp    $0x0,%rax
je     11f5 <serial_cmd+0x45>
mov    $0x0,%al
call   1080 <relay_closed@plt>
jmp    137c <serial_cmd+0x1cc>
lea    -0x50(%rbp),%rdi
lea    0xe0d(%rip),%rsi
call   10c0 <my_cmp@plt>
cmp    $0x0,%rax
je     121b <serial_cmd+0x6b>
mov    $0x0,%al
call   10a0 <relay_open@plt>
jmp    1377 <serial_cmd+0x1c7>
lea    -0x50(%rbp),%rdi
lea    0xdea(%rip),%rsi
call   10c0 <my_cmp@plt>
cmp    $0x0,%rax
je     1241 <serial_cmd+0x91>
mov    $0x0,%al
call   1090 <measure_rint@plt>
jmp    1372 <serial_cmd+0x1c2>
lea    -0x50(%rbp),%rdi
lea    0xdc7(%rip),%rsi
call   10c0 <my_cmp@plt>
cmp    $0x0,%rax
je     1267 <serial_cmd+0xb7>
mov    $0x0,%al
call   1040 <adc_test1@plt>
jmp    136d <serial_cmd+0x1bd>
lea    -0x50(%rbp),%rdi
lea    0xda4(%rip),%rsi
call   10c0 <my_cmp@plt>
cmp    $0x0,%rax
je     128d <serial_cmd+0xdd>
mov    $0x0,%al
call   10d0 <adc_test2@plt>
jmp    1368 <serial_cmd+0x1b8>
lea    -0x50(%rbp),%rdi
lea    0xd81(%rip),%rsi
call   10c0 <my_cmp@plt>
cmp    $0x0,%rax
je     12b3 <serial_cmd+0x103>
mov    $0x0,%al
call   1050 <adc_test3@plt>
jmp    1363 <serial_cmd+0x1b3>
lea    -0x50(%rbp),%rdi
lea    0xd5e(%rip),%rsi
call   10c0 <my_cmp@plt>
cmp    $0x0,%rax
je     12d9 <serial_cmd+0x129>
mov    $0x0,%al
call   10b0 <calibrate@plt>
jmp    135e <serial_cmd+0x1ae>
lea    -0x50(%rbp),%rdi
lea    0xd3c(%rip),%rsi
call   10c0 <my_cmp@plt>
cmp    $0x0,%rax
je     1306 <serial_cmd+0x156>
lea    0xd2c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1359 <serial_cmd+0x1a9>
lea    -0x50(%rbp),%rdi
lea    0xd19(%rip),%rsi
call   10c0 <my_cmp@plt>
cmp    $0x0,%rax
je     1333 <serial_cmd+0x183>
lea    0xd08(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1381 <serial_cmd+0x1d1>
lea    -0x50(%rbp),%rdi
call   1030 <my_strlen@plt>
mov    %eax,-0x54(%rbp)
lea    -0x50(%rbp),%rsi
mov    -0x54(%rbp),%edx
lea    0xce8(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1359 <serial_cmd+0x1a9>
jmp    135e <serial_cmd+0x1ae>
jmp    1363 <serial_cmd+0x1b3>
jmp    1368 <serial_cmd+0x1b8>
jmp    136d <serial_cmd+0x1bd>
jmp    1372 <serial_cmd+0x1c2>
jmp    1377 <serial_cmd+0x1c7>
jmp    137c <serial_cmd+0x1cc>
jmp    11b8 <serial_cmd+0x8>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<serial_cmd>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
lea    0xe2b(%rip),%r14
mov    %rsp,%rbx
lea    0xe2b(%rip),%r15
lea    0xe27(%rip),%r12
lea    0xe23(%rip),%r13
lea    0xe1f(%rip),%rbp
jmp    1207 <serial_cmd+0x47>
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1090 <relay_closed@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbx,%rdi
call   1070 <serial_getl@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   10d0 <my_cmp@plt>
test   %rax,%rax
jne    1200 <serial_cmd+0x40>
mov    %rbx,%rdi
mov    %r12,%rsi
call   10d0 <my_cmp@plt>
test   %rax,%rax
je     1242 <serial_cmd+0x82>
xor    %eax,%eax
call   10b0 <relay_open@plt>
jmp    1207 <serial_cmd+0x47>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10d0 <my_cmp@plt>
test   %rax,%rax
je     125b <serial_cmd+0x9b>
xor    %eax,%eax
call   10a0 <measure_rint@plt>
jmp    1207 <serial_cmd+0x47>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   10d0 <my_cmp@plt>
test   %rax,%rax
je     1274 <serial_cmd+0xb4>
xor    %eax,%eax
call   1050 <adc_test1@plt>
jmp    1207 <serial_cmd+0x47>
mov    %rbx,%rdi
lea    0xd98(%rip),%rsi
call   10d0 <my_cmp@plt>
test   %rax,%rax
je     1294 <serial_cmd+0xd4>
xor    %eax,%eax
call   10e0 <adc_test2@plt>
jmp    1207 <serial_cmd+0x47>
mov    %rbx,%rdi
lea    0xd7b(%rip),%rsi
call   10d0 <my_cmp@plt>
test   %rax,%rax
je     12b4 <serial_cmd+0xf4>
xor    %eax,%eax
call   1060 <adc_test3@plt>
jmp    1207 <serial_cmd+0x47>
mov    %rbx,%rdi
lea    0xd5e(%rip),%rsi
call   10d0 <my_cmp@plt>
test   %rax,%rax
je     12d4 <serial_cmd+0x114>
xor    %eax,%eax
call   10c0 <calibrate@plt>
jmp    1207 <serial_cmd+0x47>
mov    %rbx,%rdi
lea    0xd42(%rip),%rsi
call   10d0 <my_cmp@plt>
test   %rax,%rax
je     12f9 <serial_cmd+0x139>
lea    0xd4f(%rip),%rdi
call   1040 <puts@plt>
jmp    1207 <serial_cmd+0x47>
mov    %rbx,%rdi
lea    0xd23(%rip),%rsi
call   10d0 <my_cmp@plt>
test   %rax,%rax
jne    132d <serial_cmd+0x16d>
mov    %rbx,%rdi
call   1030 <my_strlen@plt>
lea    0xd0f(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1080 <printf@plt>
jmp    1207 <serial_cmd+0x47>
lea    0xd05(%rip),%rdi
call   1040 <puts@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"Command: \00"
@.str.1 = [3 x i8] c"rc\00"
@.str.2 = [3 x i8] c"ro\00"
@.str.3 = [3 x i8] c"ri\00"
@.str.4 = [3 x i8] c"t1\00"
@.str.5 = [3 x i8] c"t2\00"
@.str.6 = [3 x i8] c"t3\00"
@.str.7 = [4 x i8] c"cal\00"
@.str.8 = [6 x i8] c"check\00"
@.str.9 = [4 x i8] c"OK\0A\00"
@.str.10 = [5 x i8] c"quit\00"
@.str.11 = [6 x i8] c"Done\0A\00"
@.str.12 = [14 x i8] c"Got: %s (%d)\0A\00"
define void @serial_cmd() {
%1 = alloca [80 x i8]
%2 = alloca i32
br label %3
3: ; preds = %74, %0
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%6 = call i32 @serial_getl(i8* %5)
%7 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%8 = call i64 @my_cmp(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %3
%11 = call i32 (...) @relay_closed()
br label %74
12: ; preds = %3
%13 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%14 = call i64 @my_cmp(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = call i32 (...) @relay_open()
br label %73
18: ; preds = %12
%19 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%20 = call i64 @my_cmp(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = call i32 (...) @measure_rint()
br label %72
24: ; preds = %18
%25 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%26 = call i64 @my_cmp(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = call i32 (...) @adc_test1()
br label %71
30: ; preds = %24
%31 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%32 = call i64 @my_cmp(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = call i32 (...) @adc_test2()
br label %70
36: ; preds = %30
%37 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%38 = call i64 @my_cmp(i8* %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %36
%41 = call i32 (...) @adc_test3()
br label %69
42: ; preds = %36
%43 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%44 = call i64 @my_cmp(i8* %43, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %48
46: ; preds = %42
%47 = call i32 (...) @calibrate()
br label %68
48: ; preds = %42
%49 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%50 = call i64 @my_cmp(i8* %49, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%51 = icmp ne i64 %50, 0
br i1 %51, label %52, label %54
52: ; preds = %48
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
br label %67
54: ; preds = %48
%55 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%56 = call i64 @my_cmp(i8* %55, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%57 = icmp ne i64 %56, 0
br i1 %57, label %58, label %60
58: ; preds = %54
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
br label %75
60: ; preds = %54
%61 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%62 = call i32 @my_strlen(i8* %61)
store i32 %62, i32* %2
%63 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%64 = load i32, i32* %2
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0), i8* %63, i32 %64)
br label %66
66: ; preds = %60
br label %67
67: ; preds = %66, %52
br label %68
68: ; preds = %67, %46
br label %69
69: ; preds = %68, %40
br label %70
70: ; preds = %69, %34
br label %71
71: ; preds = %70, %28
br label %72
72: ; preds = %71, %22
br label %73
73: ; preds = %72, %16
br label %74
74: ; preds = %73, %10
br label %3
75: ; preds = %58
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"Command: \00"
@.str.1 = [3 x i8] c"rc\00"
@.str.2 = [3 x i8] c"ro\00"
@.str.3 = [3 x i8] c"ri\00"
@.str.4 = [3 x i8] c"t1\00"
@.str.5 = [3 x i8] c"t2\00"
@.str.6 = [3 x i8] c"t3\00"
@.str.7 = [4 x i8] c"cal\00"
@.str.8 = [6 x i8] c"check\00"
@.str.10 = [5 x i8] c"quit\00"
@.str.12 = [14 x i8] c"Got: %s (%d)\0A\00"
@str = [5 x i8] c"Done\00"
@str.13 = [3 x i8] c"OK\00"
define void @serial_cmd() {
%1 = alloca [80 x i8]
%2 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %15, %0
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @serial_getl(i8* %2)
%6 = call i64 @my_cmp(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %3
%9 = call i32 (...) @relay_closed()
br label %15
10: ; preds = %3
%11 = call i64 @my_cmp(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = call i32 (...) @relay_open()
br label %15
15: ; preds = %13, %24, %34, %44, %51, %39, %29, %19, %8
br label %3
16: ; preds = %10
%17 = call i64 @my_cmp(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %16
%20 = call i32 (...) @measure_rint()
br label %15
21: ; preds = %16
%22 = call i64 @my_cmp(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %26, label %24
24: ; preds = %21
%25 = call i32 (...) @adc_test1()
br label %15
26: ; preds = %21
%27 = call i64 @my_cmp(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %31, label %29
29: ; preds = %26
%30 = call i32 (...) @adc_test2()
br label %15
31: ; preds = %26
%32 = call i64 @my_cmp(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %36, label %34
34: ; preds = %31
%35 = call i32 (...) @adc_test3()
br label %15
36: ; preds = %31
%37 = call i64 @my_cmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %41, label %39
39: ; preds = %36
%40 = call i32 (...) @calibrate()
br label %15
41: ; preds = %36
%42 = call i64 @my_cmp(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %46, label %44
44: ; preds = %41
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.13, i64 0, i64 0))
br label %15
46: ; preds = %41
%47 = call i64 @my_cmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
br i1 %48, label %51, label %49
49: ; preds = %46
%50 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
ret void
51: ; preds = %46
%52 = call i32 @my_strlen(i8* %2)
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0), i8* %2, i32 %52)
br label %15
}