#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*/ gpio_init(int);
int /*<<< orphan*/ gpio_output(int, int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ reg_option(int, int, int);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ usleep(int);
int main(int argc, char **argv) {
  int fd, fd_temp;
  int err;
  int len;
  int i;
  char rcv_buf[100];
  char send_buf[20] = "AT+IPR?";
  send_buf[7] = 0x0D;
  send_buf[8] = 0x0A;
  if (argc < 3) {
    printf("Usage: %s 3g/4g 0/1\n", argv[0]);
    return -1;
  }
  if (0 == strcmp(argv[1], "4g")) {
    if ((0 == strcmp(argv[2], "0")) || (0 == strcmp(argv[2], "1"))) {
      gpio_init(28);
      gpio_init(29);
      gpio_init(27);
      gpio_output(27, 0);
      gpio_output(28, 1);
      gpio_output(29, 0);
      usleep(500000);
      if (0 == strcmp(argv[2], "1")) {
        gpio_output(29, 1);
      }
    }
  } else if (0 == strcmp(argv[1], "3g")) {
    if ((0 == strcmp(argv[2], "0")) || (0 == strcmp(argv[2], "1"))) {
      reg_option(0X10000060, 0x1 << 6, 0x3 << 6);
      reg_option(0X10000060, 0x1 << 2, 0x3 << 2);
      gpio_init(17);
      gpio_init(16);
      gpio_init(14);
      gpio_init(1);
      gpio_output(1, 0);
      gpio_output(16, 1);
      gpio_output(14, 0);
      gpio_output(17, 0);
      usleep(200000);
      gpio_output(14, 1);
      gpio_output(17, 1);
      usleep(500000);
      if (0 == strcmp(argv[2], "1")) {
        gpio_output(16, 0);
        usleep(500000);
        gpio_output(16, 1);
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xe80(%rip),%rax
mov    %rax,-0xb0(%rbp)
mov    0xe7a(%rip),%rax
mov    %rax,-0xa8(%rbp)
mov    0xe75(%rip),%eax
mov    %eax,-0xa0(%rbp)
movb   $0xd,-0xa9(%rbp)
movb   $0xa,-0xa8(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11d8 <main+0x78>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe4d(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1440 <main+0x2e0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe42(%rip),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    12c8 <main+0x168>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe23(%rip),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     123e <main+0xde>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe03(%rip),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    12c3 <main+0x163>
mov    $0x1c,%edi
call   1070 <gpio_init@plt>
mov    $0x1d,%edi
call   1070 <gpio_init@plt>
mov    $0x1b,%edi
call   1070 <gpio_init@plt>
mov    $0x1b,%edi
xor    %esi,%esi
call   1060 <gpio_output@plt>
mov    $0x1c,%edi
mov    $0x1,%esi
call   1060 <gpio_output@plt>
mov    $0x1d,%edi
xor    %esi,%esi
call   1060 <gpio_output@plt>
mov    $0x7a120,%edi
call   1080 <usleep@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd92(%rip),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    12be <main+0x15e>
mov    $0x1d,%edi
mov    $0x1,%esi
call   1060 <gpio_output@plt>
jmp    12c3 <main+0x163>
jmp    1439 <main+0x2d9>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd59(%rip),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1434 <main+0x2d4>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd33(%rip),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     132e <main+0x1ce>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd13(%rip),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    142f <main+0x2cf>
mov    $0x10000060,%edi
mov    $0x40,%esi
mov    $0xc0,%edx
call   1050 <reg_option@plt>
mov    $0x10000060,%edi
mov    $0x4,%esi
mov    $0xc,%edx
call   1050 <reg_option@plt>
mov    $0x11,%edi
call   1070 <gpio_init@plt>
mov    $0x10,%edi
call   1070 <gpio_init@plt>
mov    $0xe,%edi
call   1070 <gpio_init@plt>
mov    $0x1,%edi
call   1070 <gpio_init@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1060 <gpio_output@plt>
mov    $0x10,%edi
mov    $0x1,%esi
call   1060 <gpio_output@plt>
mov    $0xe,%edi
xor    %esi,%esi
call   1060 <gpio_output@plt>
mov    $0x11,%edi
xor    %esi,%esi
call   1060 <gpio_output@plt>
mov    $0x30d40,%edi
call   1080 <usleep@plt>
mov    $0xe,%edi
mov    $0x1,%esi
call   1060 <gpio_output@plt>
mov    $0x11,%edi
mov    $0x1,%esi
call   1060 <gpio_output@plt>
mov    $0x7a120,%edi
call   1080 <usleep@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xc3c(%rip),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    142a <main+0x2ca>
mov    $0x10,%edi
xor    %esi,%esi
call   1060 <gpio_output@plt>
mov    $0x7a120,%edi
call   1080 <usleep@plt>
mov    $0x10,%edi
mov    $0x1,%esi
call   1060 <gpio_output@plt>
jmp    142f <main+0x2cf>
jmp    1434 <main+0x2d4>
jmp    1439 <main+0x2d9>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x2,%edi
jg     1184 <main+0x24>
mov    (%rbx),%rsi
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
mov    $0xffffffff,%ebp
jmp    1379 <main+0x219>
mov    0x8(%rbx),%rdi
lea    0xe86(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     12d8 <main+0x178>
mov    0x8(%rbx),%rdi
lea    0xe74(%rip),%rsi
call   1040 <strcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
jne    1379 <main+0x219>
mov    0x10(%rbx),%rdi
lea    0xe55(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11e6 <main+0x86>
mov    0x10(%rbx),%rdi
lea    0xe42(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1379 <main+0x219>
mov    $0x10000060,%edi
mov    $0x40,%esi
mov    $0xc0,%edx
call   1050 <reg_option@plt>
mov    $0x10000060,%edi
mov    $0x4,%esi
mov    $0xc,%edx
call   1050 <reg_option@plt>
mov    $0x11,%edi
call   1070 <gpio_init@plt>
mov    $0x10,%edi
call   1070 <gpio_init@plt>
mov    $0xe,%edi
call   1070 <gpio_init@plt>
mov    $0x1,%edi
call   1070 <gpio_init@plt>
xor    %ebp,%ebp
mov    $0x1,%edi
xor    %esi,%esi
call   1060 <gpio_output@plt>
mov    $0x10,%edi
mov    $0x1,%esi
call   1060 <gpio_output@plt>
mov    $0xe,%edi
xor    %esi,%esi
call   1060 <gpio_output@plt>
mov    $0x11,%edi
xor    %esi,%esi
call   1060 <gpio_output@plt>
mov    $0x30d40,%edi
call   1080 <usleep@plt>
mov    $0xe,%edi
mov    $0x1,%esi
call   1060 <gpio_output@plt>
mov    $0x11,%edi
mov    $0x1,%esi
call   1060 <gpio_output@plt>
mov    $0x7a120,%edi
call   1080 <usleep@plt>
mov    0x10(%rbx),%rdi
lea    0xd72(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1379 <main+0x219>
xor    %ebp,%ebp
mov    $0x10,%edi
xor    %esi,%esi
call   1060 <gpio_output@plt>
mov    $0x7a120,%edi
call   1080 <usleep@plt>
mov    $0x10,%edi
jmp    136f <main+0x20f>
mov    0x10(%rbx),%rdi
lea    0xd35(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1304 <main+0x1a4>
mov    0x10(%rbx),%rdi
lea    0xd22(%rip),%rsi
call   1040 <strcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
jne    1379 <main+0x219>
mov    $0x1c,%edi
call   1070 <gpio_init@plt>
mov    $0x1d,%edi
call   1070 <gpio_init@plt>
mov    $0x1b,%edi
call   1070 <gpio_init@plt>
xor    %ebp,%ebp
mov    $0x1b,%edi
xor    %esi,%esi
call   1060 <gpio_output@plt>
mov    $0x1c,%edi
mov    $0x1,%esi
call   1060 <gpio_output@plt>
mov    $0x1d,%edi
xor    %esi,%esi
call   1060 <gpio_output@plt>
mov    $0x7a120,%edi
call   1080 <usleep@plt>
mov    0x10(%rbx),%rdi
lea    0xcba(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1379 <main+0x219>
mov    $0x1d,%edi
mov    $0x1,%esi
call   1060 <gpio_output@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.send_buf = [20 x i8] c"AT+IPR?\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [21 x i8] c"Usage: %s 3g/4g 0/1\0A\00"
@.str.1 = [3 x i8] c"4g\00"
@.str.2 = [2 x i8] c"0\00"
@.str.3 = [2 x i8] c"1\00"
@.str.4 = [3 x i8] c"3g\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 i32
%10 = alloca i32
%11 = alloca [100 x i8]
%12 = alloca [20 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = bitcast [20 x i8]* %12 to i8*
%14 = getelementptr inbounds [20 x i8], [20 x i8]* %12, i64 0, i64 7
store i8 13, i8* %14
%15 = getelementptr inbounds [20 x i8], [20 x i8]* %12, i64 0, i64 8
store i8 10, i8* %15
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 3
br i1 %17, label %18, label %23
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
%22 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %21)
store i32 -1, i32* %3
br label %104
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%28 = icmp eq i64 0, %27
br i1 %28, label %29, label %58
29: ; preds = %23
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 2
%32 = load i8*, i8** %31
%33 = call i64 @strcmp(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%34 = icmp eq i64 0, %33
br i1 %34, label %41, label %35
35: ; preds = %29
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 2
%38 = load i8*, i8** %37
%39 = call i64 @strcmp(i8* %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%40 = icmp eq i64 0, %39
br i1 %40, label %41, label %57
41: ; preds = %35, %29
%42 = call i32 @gpio_init(i32 28)
%43 = call i32 @gpio_init(i32 29)
%44 = call i32 @gpio_init(i32 27)
%45 = call i32 @gpio_output(i32 27, i32 0)
%46 = call i32 @gpio_output(i32 28, i32 1)
%47 = call i32 @gpio_output(i32 29, i32 0)
%48 = call i32 @usleep(i32 500000)
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 2
%51 = load i8*, i8** %50
%52 = call i64 @strcmp(i8* %51, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%53 = icmp eq i64 0, %52
br i1 %53, label %54, label %56
54: ; preds = %41
%55 = call i32 @gpio_output(i32 29, i32 1)
br label %56
56: ; preds = %54, %41
br label %57
57: ; preds = %56, %35
br label %103
58: ; preds = %23
%59 = load i8**, i8*** %5
%60 = getelementptr inbounds i8*, i8** %59, i64 1
%61 = load i8*, i8** %60
%62 = call i64 @strcmp(i8* %61, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%63 = icmp eq i64 0, %62
br i1 %63, label %64, label %102
64: ; preds = %58
%65 = load i8**, i8*** %5
%66 = getelementptr inbounds i8*, i8** %65, i64 2
%67 = load i8*, i8** %66
%68 = call i64 @strcmp(i8* %67, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%69 = icmp eq i64 0, %68
br i1 %69, label %76, label %70
70: ; preds = %64
%71 = load i8**, i8*** %5
%72 = getelementptr inbounds i8*, i8** %71, i64 2
%73 = load i8*, i8** %72
%74 = call i64 @strcmp(i8* %73, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%75 = icmp eq i64 0, %74
br i1 %75, label %76, label %101
76: ; preds = %70, %64
%77 = call i32 @reg_option(i32 268435552, i32 64, i32 192)
%78 = call i32 @reg_option(i32 268435552, i32 4, i32 12)
%79 = call i32 @gpio_init(i32 17)
%80 = call i32 @gpio_init(i32 16)
%81 = call i32 @gpio_init(i32 14)
%82 = call i32 @gpio_init(i32 1)
%83 = call i32 @gpio_output(i32 1, i32 0)
%84 = call i32 @gpio_output(i32 16, i32 1)
%85 = call i32 @gpio_output(i32 14, i32 0)
%86 = call i32 @gpio_output(i32 17, i32 0)
%87 = call i32 @usleep(i32 200000)
%88 = call i32 @gpio_output(i32 14, i32 1)
%89 = call i32 @gpio_output(i32 17, i32 1)
%90 = call i32 @usleep(i32 500000)
%91 = load i8**, i8*** %5
%92 = getelementptr inbounds i8*, i8** %91, i64 2
%93 = load i8*, i8** %92
%94 = call i64 @strcmp(i8* %93, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%95 = icmp eq i64 0, %94
br i1 %95, label %96, label %100
96: ; preds = %76
%97 = call i32 @gpio_output(i32 16, i32 0)
%98 = call i32 @usleep(i32 500000)
%99 = call i32 @gpio_output(i32 16, i32 1)
br label %100
100: ; preds = %96, %76
br label %101
101: ; preds = %100, %70
br label %102
102: ; preds = %101, %58
br label %103
103: ; preds = %102, %57
store i32 0, i32* %3
br label %104
104: ; preds = %103, %18
%105 = load i32, i32* %3
ret i32 %105
}

LLVM IR (-O2):
@.str = [21 x i8] c"Usage: %s 3g/4g 0/1\0A\00"
@.str.1 = [3 x i8] c"4g\00"
@.str.2 = [2 x i8] c"0\00"
@.str.3 = [2 x i8] c"1\00"
@.str.4 = [3 x i8] c"3g\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %69
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %34
12: ; preds = %7
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = tail call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %21, label %17
17: ; preds = %12
%18 = load i8*, i8** %13
%19 = tail call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %69
21: ; preds = %17, %12
%22 = tail call i32 @gpio_init(i32 28)
%23 = tail call i32 @gpio_init(i32 29)
%24 = tail call i32 @gpio_init(i32 27)
%25 = tail call i32 @gpio_output(i32 27, i32 0)
%26 = tail call i32 @gpio_output(i32 28, i32 1)
%27 = tail call i32 @gpio_output(i32 29, i32 0)
%28 = tail call i32 @usleep(i32 500000)
%29 = load i8*, i8** %13
%30 = tail call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %69
32: ; preds = %21
%33 = tail call i32 @gpio_output(i32 29, i32 1)
br label %69
34: ; preds = %7
%35 = load i8*, i8** %8
%36 = tail call i64 @strcmp(i8* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %69
38: ; preds = %34
%39 = getelementptr inbounds i8*, i8** %1, i64 2
%40 = load i8*, i8** %39
%41 = tail call i64 @strcmp(i8* %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%42 = icmp eq i64 %41, 0
br i1 %42, label %47, label %43
43: ; preds = %38
%44 = load i8*, i8** %39
%45 = tail call i64 @strcmp(i8* %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %69
47: ; preds = %43, %38
%48 = tail call i32 @reg_option(i32 268435552, i32 64, i32 192)
%49 = tail call i32 @reg_option(i32 268435552, i32 4, i32 12)
%50 = tail call i32 @gpio_init(i32 17)
%51 = tail call i32 @gpio_init(i32 16)
%52 = tail call i32 @gpio_init(i32 14)
%53 = tail call i32 @gpio_init(i32 1)
%54 = tail call i32 @gpio_output(i32 1, i32 0)
%55 = tail call i32 @gpio_output(i32 16, i32 1)
%56 = tail call i32 @gpio_output(i32 14, i32 0)
%57 = tail call i32 @gpio_output(i32 17, i32 0)
%58 = tail call i32 @usleep(i32 200000)
%59 = tail call i32 @gpio_output(i32 14, i32 1)
%60 = tail call i32 @gpio_output(i32 17, i32 1)
%61 = tail call i32 @usleep(i32 500000)
%62 = load i8*, i8** %39
%63 = tail call i64 @strcmp(i8* %62, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%64 = icmp eq i64 %63, 0
br i1 %64, label %65, label %69
65: ; preds = %47
%66 = tail call i32 @gpio_output(i32 16, i32 0)
%67 = tail call i32 @usleep(i32 500000)
%68 = tail call i32 @gpio_output(i32 16, i32 1)
br label %69
69: ; preds = %21, %32, %17, %43, %65, %47, %34, %4
%70 = phi i32 [ -1, %4 ], [ 0, %34 ], [ 0, %47 ], [ 0, %65 ], [ 0, %43 ], [ 0, %17 ], [ 0, %32 ], [ 0, %21 ]
ret i32 %70
}