#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 */
typedef int /*<<< orphan*/ useconds_t;
struct instrument {
  int dummy;
};
typedef int /*<<< orphan*/ rsp;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ inst_clr(struct instrument *, int);
int /*<<< orphan*/ inst_loc(struct instrument *);
int /*<<< orphan*/ inst_qrystr(struct instrument *, char *, char *, int);
int /*<<< orphan*/ inst_rdstr(struct instrument *, char *, int);
int /*<<< orphan*/ inst_rsp(struct instrument *, unsigned char *);
int /*<<< orphan*/ inst_wrtstr(struct instrument *, char *);
int /*<<< orphan*/ optarg;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcmp(char *, char *);
int strlen(char *);
double strtod(char *, int /*<<< orphan*/ *);
scalar_t__ strtoul(int /*<<< orphan*/, int /*<<< orphan*/ *,
                   int /*<<< orphan*/);
int /*<<< orphan*/ usleep(int /*<<< orphan*/);
int command(struct instrument *gd, int ac, char **av) {
  int count = 0;
  if (!strcmp(av[0], "local")) {
    inst_loc(gd);
    count++;
  } else if (!strcmp(av[0], "clear")) {
    inst_clr(gd, 100000);
    count++;
  } else if (!strcmp(av[0], "query")) {
    char rsp[4096];
    if (ac < 2) {
      printf("query requires an argument\n");
    } else {
      (void)inst_qrystr(gd, av[1], rsp, sizeof(rsp));
      printf("%s\n", rsp);
    }
    count += 2;
  } else if (!strcmp(av[0], "write")) {
    if (ac < 2) {
      printf("write requires an argument\n");
    } else {
      inst_wrtstr(gd, av[1]);
    }
    count += 2;
  } else if (!strcmp(av[0], "read") || !strcmp(av[0], "?")) {
    char rsp[4096];
    inst_rdstr(gd, rsp, sizeof(rsp));
    printf("%s\n", rsp);
    count++;
  } else if (!strcmp(av[0], "delay")) {
    if (ac < 2) {
      printf("delay requires a seconds argument\n");
    } else {
      usleep((useconds_t)(strtod(av[1], NULL) * 1000000.0));
    }
    count += 2;
  } else if (!strcmp(av[0], "status")) {
    unsigned char status, mask;
    if (ac < 2) {
      printf("status requires a mask argument\n");
    } else {
      mask = (unsigned char)strtoul(optarg, NULL, 0);
      (void)inst_rsp(gd, &status);
      printf("%hhu\n", status);
      if ((status & mask) != 0)
        exit(1);
    }
    count += 2;
  } else if (!strcmp(av[0], "help")) {
    printf("Command help:\n"
           "    <command>     write gpib message <command>\n"
           "    <query?>      write <command>, read response\n"
           "    quit/exit     exit shell\n"
           "    clear         send gpib clear command\n"
           "    local         send gpib local command\n"
           "    status MASK   read gpib status, exit if MASK matches\n"
           "    read/?        read gpib message\n"
           "    write MESSAGE write gpib message\n"
           "    query MESSAGE write gpib message, then read\n"
           "    delay SEC     delay SEC seconds\n"
           "    help          dispaly this help\n");
    count++;
  } else if (av[0][strlen(av[0]) - 1] == '?') {
    char rsp[4096];
    (void)inst_qrystr(gd, av[0], rsp, sizeof(rsp));
    printf("%s\n", rsp);
    count++;
  } else {
    inst_wrtstr(gd, av[0]);
    count++;
  }
  return count;
}


x86 assembly (clang, -O0):
<command>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3040,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
lea    0xe0d(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1220 <command+0x50>
mov    -0x8(%rbp),%rdi
call   10e0 <inst_loc@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    15a2 <command+0x3d2>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
lea    0xde0(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1258 <command+0x88>
mov    -0x8(%rbp),%rdi
mov    $0x186a0,%esi
call   10b0 <inst_clr@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    159d <command+0x3cd>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
lea    0xdae(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    12d1 <command+0x101>
cmpl   $0x2,-0xc(%rbp)
jge    1291 <command+0xc1>
lea    0xd95(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    12c3 <command+0xf3>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rsi
lea    -0x1020(%rbp),%rdx
mov    $0x1000,%ecx
call   1050 <inst_qrystr@plt>
lea    -0x1020(%rbp),%rsi
lea    0xd7a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
jmp    1598 <command+0x3c8>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
lea    0xd5b(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1329 <command+0x159>
cmpl   $0x2,-0xc(%rbp)
jge    130a <command+0x13a>
lea    0xd42(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    131b <command+0x14b>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rsi
call   1080 <inst_wrtstr@plt>
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
jmp    1593 <command+0x3c3>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
lea    0xd25(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
je     1361 <command+0x191>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
lea    0xd0e(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1399 <command+0x1c9>
mov    -0x8(%rbp),%rdi
lea    -0x2020(%rbp),%rsi
mov    $0x1000,%edx
call   10a0 <inst_rdstr@plt>
lea    -0x2020(%rbp),%rsi
lea    0xcb2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    158e <command+0x3be>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
lea    0xcbc(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1406 <command+0x236>
cmpl   $0x2,-0xc(%rbp)
jge    13d2 <command+0x202>
lea    0xca3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    13f8 <command+0x228>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <strtod@plt>
movsd  0xc15(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   10f0 <usleep@plt>
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
jmp    1589 <command+0x3b9>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
lea    0xc78(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    14b4 <command+0x2e4>
cmpl   $0x2,-0xc(%rbp)
jge    143f <command+0x26f>
lea    0xc60(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    14a6 <command+0x2d6>
mov    0x2bb2(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   10c0 <strtoul@plt>
mov    %al,-0x2022(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x2021(%rbp),%rsi
call   1090 <inst_rsp@plt>
movzbl -0x2021(%rbp),%esi
lea    0xc3d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movzbl -0x2021(%rbp),%eax
movzbl -0x2022(%rbp),%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     14a1 <command+0x2d1>
mov    $0x1,%edi
call   10d0 <exit@plt>
jmp    14a6 <command+0x2d6>
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
jmp    1584 <command+0x3b4>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
lea    0xbf8(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    14ec <command+0x31c>
lea    0xbe8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    157f <command+0x3af>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x3038(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x3038(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3f,%eax
jne    1561 <command+0x391>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
lea    -0x3030(%rbp),%rdx
mov    $0x1000,%ecx
call   1050 <inst_qrystr@plt>
lea    -0x3030(%rbp),%rsi
lea    0xaea(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    157a <command+0x3aa>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
call   1080 <inst_wrtstr@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    157f <command+0x3af>
jmp    1584 <command+0x3b4>
jmp    1589 <command+0x3b9>
jmp    158e <command+0x3be>
jmp    1593 <command+0x3c3>
jmp    1598 <command+0x3c8>
jmp    159d <command+0x3cd>
jmp    15a2 <command+0x3d2>
mov    -0x1c(%rbp),%eax
add    $0x3040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<command>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x1008,%rsp
mov    %rdx,%r15
mov    %esi,%ebp
mov    %rdi,%r14
mov    (%rdx),%rbx
lea    0xe09(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %eax,%eax
je     12f4 <command+0x114>
lea    0xdf8(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %eax,%eax
je     12fe <command+0x11e>
lea    0xde7(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %eax,%eax
je     130d <command+0x12d>
lea    0xdd6(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %eax,%eax
je     133d <command+0x15d>
lea    0xdc5(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %eax,%eax
je     131b <command+0x13b>
lea    0xdb3(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %eax,%eax
je     131b <command+0x13b>
lea    0xd9e(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %eax,%eax
je     138b <command+0x1ab>
lea    0xd8d(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %eax,%eax
je     1399 <command+0x1b9>
lea    0xfcf(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %eax,%eax
je     13c5 <command+0x1e5>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
cmpb   $0x3f,-0x1(%rax,%rbx,1)
jne    13d1 <command+0x1f1>
mov    (%r15),%rsi
mov    %rsp,%rbx
mov    %r14,%rdi
mov    %rbx,%rdx
mov    $0x1000,%ecx
call   1060 <inst_qrystr@plt>
jmp    132e <command+0x14e>
mov    %r14,%rdi
call   10f0 <inst_loc@plt>
jmp    1336 <command+0x156>
mov    %r14,%rdi
mov    $0x186a0,%esi
call   10c0 <inst_clr@plt>
jmp    1336 <command+0x156>
cmp    $0x1,%ebp
jg     134b <command+0x16b>
lea    0xd21(%rip),%rdi
jmp    1365 <command+0x185>
mov    %rsp,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x1000,%edx
call   10b0 <inst_rdstr@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
jmp    136f <command+0x18f>
cmp    $0x1,%ebp
jg     137d <command+0x19d>
lea    0xd0c(%rip),%rdi
jmp    1365 <command+0x185>
mov    0x8(%r15),%rsi
mov    %rsp,%rbx
mov    %r14,%rdi
mov    %rbx,%rdx
mov    $0x1000,%ecx
call   1060 <inst_qrystr@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    $0x2,%eax
add    $0x1008,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%r15),%rsi
mov    %r14,%rdi
call   1090 <inst_wrtstr@plt>
jmp    136a <command+0x18a>
cmp    $0x1,%ebp
jg     13a7 <command+0x1c7>
lea    0xcd9(%rip),%rdi
jmp    1365 <command+0x185>
cmp    $0x1,%ebp
jg     13e1 <command+0x201>
lea    0xced(%rip),%rdi
jmp    1365 <command+0x185>
mov    0x8(%r15),%rdi
xor    %esi,%esi
call   1040 <strtod@plt>
mulsd  0xc46(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1100 <usleep@plt>
jmp    136a <command+0x18a>
lea    0xce6(%rip),%rdi
jmp    1331 <command+0x151>
mov    (%r15),%rsi
mov    %r14,%rdi
call   1090 <inst_wrtstr@plt>
jmp    1336 <command+0x156>
mov    0x2c10(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
xor    %edx,%edx
call   10d0 <strtoul@plt>
mov    %rax,%rbx
mov    %rsp,%rsi
mov    %r14,%rdi
call   10a0 <inst_rsp@plt>
movzbl (%rsp),%esi
lea    0xc28(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
movzbl (%rsp),%eax
test   %ebx,%eax
je     136a <command+0x18a>
mov    $0x1,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
%struct.instrument = type { i32 }
@.str = [6 x i8] c"local\00"
@.str.1 = [6 x i8] c"clear\00"
@.str.2 = [6 x i8] c"query\00"
@.str.3 = [28 x i8] c"query requires an argument\0A\00"
@.str.4 = [4 x i8] c"%s\0A\00"
@.str.5 = [6 x i8] c"write\00"
@.str.6 = [28 x i8] c"write requires an argument\0A\00"
@.str.7 = [5 x i8] c"read\00"
@.str.8 = [2 x i8] c"?\00"
@.str.9 = [6 x i8] c"delay\00"
@.str.10 = [35 x i8] c"delay requires a seconds argument\0A\00"
@.str.11 = [7 x i8] c"status\00"
@.str.12 = [33 x i8] c"status requires a mask argument\0A\00"
@optarg = global i32 0
@.str.13 = [6 x i8] c"%hhu\0A\00"
@.str.14 = [5 x i8] c"help\00"
@.str.15 = [474 x i8] c"Command help:\0A <command> write gpib message <command>\0A <query?> write <command>, read response\0A quit/exit exit shell\0A clear send gpib clear command\0A local send gpib local command\0A status MASK read gpib status, exit if MASK matches\0A read/? read gpib message\0A write MESSAGE write gpib message\0A query MESSAGE write gpib message, then read\0A delay SEC delay SEC seconds\0A help dispaly this help\0A\00"
define i32 @command(%struct.instrument* %0, i32 %1, i8** %2) {
%4 = alloca %struct.instrument*
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i32
%8 = alloca [4096 x i8]
%9 = alloca [4096 x i8]
%10 = alloca i8
%11 = alloca i8
%12 = alloca [4096 x i8]
store %struct.instrument* %0, %struct.instrument** %4
store i32 %1, i32* %5
store i8** %2, i8*** %6
store i32 0, i32* %7
%13 = load i8**, i8*** %6
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 @strcmp(i8* %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%17 = icmp ne i32 %16, 0
br i1 %17, label %23, label %18
18: ; preds = %3
%19 = load %struct.instrument*, %struct.instrument** %4
%20 = call i32 @inst_loc(%struct.instrument* %19)
%21 = load i32, i32* %7
%22 = add nsw i32 %21, 1
store i32 %22, i32* %7
br label %202
23: ; preds = %3
%24 = load i8**, i8*** %6
%25 = getelementptr inbounds i8*, i8** %24, i64 0
%26 = load i8*, i8** %25
%27 = call i32 @strcmp(i8* %26, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%28 = icmp ne i32 %27, 0
br i1 %28, label %34, label %29
29: ; preds = %23
%30 = load %struct.instrument*, %struct.instrument** %4
%31 = call i32 @inst_clr(%struct.instrument* %30, i32 100000)
%32 = load i32, i32* %7
%33 = add nsw i32 %32, 1
store i32 %33, i32* %7
br label %201
34: ; preds = %23
%35 = load i8**, i8*** %6
%36 = getelementptr inbounds i8*, i8** %35, i64 0
%37 = load i8*, i8** %36
%38 = call i32 @strcmp(i8* %37, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%39 = icmp ne i32 %38, 0
br i1 %39, label %57, label %40
40: ; preds = %34
%41 = load i32, i32* %5
%42 = icmp slt i32 %41, 2
br i1 %42, label %43, label %45
43: ; preds = %40
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
br label %54
45: ; preds = %40
%46 = load %struct.instrument*, %struct.instrument** %4
%47 = load i8**, i8*** %6
%48 = getelementptr inbounds i8*, i8** %47, i64 1
%49 = load i8*, i8** %48
%50 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%51 = call i32 @inst_qrystr(%struct.instrument* %46, i8* %49, i8* %50, i32 4096)
%52 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %52)
br label %54
54: ; preds = %45, %43
%55 = load i32, i32* %7
%56 = add nsw i32 %55, 2
store i32 %56, i32* %7
br label %200
57: ; preds = %34
%58 = load i8**, i8*** %6
%59 = getelementptr inbounds i8*, i8** %58, i64 0
%60 = load i8*, i8** %59
%61 = call i32 @strcmp(i8* %60, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%62 = icmp ne i32 %61, 0
br i1 %62, label %77, label %63
63: ; preds = %57
%64 = load i32, i32* %5
%65 = icmp slt i32 %64, 2
br i1 %65, label %66, label %68
66: ; preds = %63
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
br label %74
68: ; preds = %63
%69 = load %struct.instrument*, %struct.instrument** %4
%70 = load i8**, i8*** %6
%71 = getelementptr inbounds i8*, i8** %70, i64 1
%72 = load i8*, i8** %71
%73 = call i32 @inst_wrtstr(%struct.instrument* %69, i8* %72)
br label %74
74: ; preds = %68, %66
%75 = load i32, i32* %7
%76 = add nsw i32 %75, 2
store i32 %76, i32* %7
br label %199
77: ; preds = %57
%78 = load i8**, i8*** %6
%79 = getelementptr inbounds i8*, i8** %78, i64 0
%80 = load i8*, i8** %79
%81 = call i32 @strcmp(i8* %80, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%82 = icmp ne i32 %81, 0
br i1 %82, label %83, label %89
83: ; preds = %77
%84 = load i8**, i8*** %6
%85 = getelementptr inbounds i8*, i8** %84, i64 0
%86 = load i8*, i8** %85
%87 = call i32 @strcmp(i8* %86, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%88 = icmp ne i32 %87, 0
br i1 %88, label %97, label %89
89: ; preds = %83, %77
%90 = load %struct.instrument*, %struct.instrument** %4
%91 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%92 = call i32 @inst_rdstr(%struct.instrument* %90, i8* %91, i32 4096)
%93 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %93)
%95 = load i32, i32* %7
%96 = add nsw i32 %95, 1
store i32 %96, i32* %7
br label %198
97: ; preds = %83
%98 = load i8**, i8*** %6
%99 = getelementptr inbounds i8*, i8** %98, i64 0
%100 = load i8*, i8** %99
%101 = call i32 @strcmp(i8* %100, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%102 = icmp ne i32 %101, 0
br i1 %102, label %119, label %103
103: ; preds = %97
%104 = load i32, i32* %5
%105 = icmp slt i32 %104, 2
br i1 %105, label %106, label %108
106: ; preds = %103
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.10, i64 0, i64 0))
br label %116
108: ; preds = %103
%109 = load i8**, i8*** %6
%110 = getelementptr inbounds i8*, i8** %109, i64 1
%111 = load i8*, i8** %110
%112 = call double @strtod(i8* %111, i32* null)
%113 = fmul double %112, 1.000000e+06
%114 = fptosi double %113 to i32
%115 = call i32 @usleep(i32 %114)
br label %116
116: ; preds = %108, %106
%117 = load i32, i32* %7
%118 = add nsw i32 %117, 2
store i32 %118, i32* %7
br label %197
119: ; preds = %97
%120 = load i8**, i8*** %6
%121 = getelementptr inbounds i8*, i8** %120, i64 0
%122 = load i8*, i8** %121
%123 = call i32 @strcmp(i8* %122, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
%124 = icmp ne i32 %123, 0
br i1 %124, label %151, label %125
125: ; preds = %119
%126 = load i32, i32* %5
%127 = icmp slt i32 %126, 2
br i1 %127, label %128, label %130
128: ; preds = %125
%129 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.12, i64 0, i64 0))
br label %148
130: ; preds = %125
%131 = load i32, i32* @optarg
%132 = call i64 @strtoul(i32 %131, i32* null, i32 0)
%133 = trunc i64 %132 to i8
store i8 %133, i8* %11
%134 = load %struct.instrument*, %struct.instrument** %4
%135 = call i32 @inst_rsp(%struct.instrument* %134, i8* %10)
%136 = load i8, i8* %10
%137 = zext i8 %136 to i32
%138 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0), i32 %137)
%139 = load i8, i8* %10
%140 = zext i8 %139 to i32
%141 = load i8, i8* %11
%142 = zext i8 %141 to i32
%143 = and i32 %140, %142
%144 = icmp ne i32 %143, 0
br i1 %144, label %145, label %147
145: ; preds = %130
%146 = call i32 @exit(i32 1)
unreachable
147: ; preds = %130
br label %148
148: ; preds = %147, %128
%149 = load i32, i32* %7
%150 = add nsw i32 %149, 2
store i32 %150, i32* %7
br label %196
151: ; preds = %119
%152 = load i8**, i8*** %6
%153 = getelementptr inbounds i8*, i8** %152, i64 0
%154 = load i8*, i8** %153
%155 = call i32 @strcmp(i8* %154, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0))
%156 = icmp ne i32 %155, 0
br i1 %156, label %161, label %157
157: ; preds = %151
%158 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([474 x i8], [474 x i8]* @.str.15, i64 0, i64 0))
%159 = load i32, i32* %7
%160 = add nsw i32 %159, 1
store i32 %160, i32* %7
br label %195
161: ; preds = %151
%162 = load i8**, i8*** %6
%163 = getelementptr inbounds i8*, i8** %162, i64 0
%164 = load i8*, i8** %163
%165 = load i8**, i8*** %6
%166 = getelementptr inbounds i8*, i8** %165, i64 0
%167 = load i8*, i8** %166
%168 = call i32 @strlen(i8* %167)
%169 = sub nsw i32 %168, 1
%170 = sext i32 %169 to i64
%171 = getelementptr inbounds i8, i8* %164, i64 %170
%172 = load i8, i8* %171
%173 = sext i8 %172 to i32
%174 = icmp eq i32 %173, 63
br i1 %174, label %175, label %186
175: ; preds = %161
%176 = load %struct.instrument*, %struct.instrument** %4
%177 = load i8**, i8*** %6
%178 = getelementptr inbounds i8*, i8** %177, i64 0
%179 = load i8*, i8** %178
%180 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%181 = call i32 @inst_qrystr(%struct.instrument* %176, i8* %179, i8* %180, i32 4096)
%182 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%183 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %182)
%184 = load i32, i32* %7
%185 = add nsw i32 %184, 1
store i32 %185, i32* %7
br label %194
186: ; preds = %161
%187 = load %struct.instrument*, %struct.instrument** %4
%188 = load i8**, i8*** %6
%189 = getelementptr inbounds i8*, i8** %188, i64 0
%190 = load i8*, i8** %189
%191 = call i32 @inst_wrtstr(%struct.instrument* %187, i8* %190)
%192 = load i32, i32* %7
%193 = add nsw i32 %192, 1
store i32 %193, i32* %7
br label %194
194: ; preds = %186, %175
br label %195
195: ; preds = %194, %157
br label %196
196: ; preds = %195, %148
br label %197
197: ; preds = %196, %116
br label %198
198: ; preds = %197, %89
br label %199
199: ; preds = %198, %74
br label %200
200: ; preds = %199, %54
br label %201
201: ; preds = %200, %29
br label %202
202: ; preds = %201, %18
%203 = load i32, i32* %7
ret i32 %203
}

LLVM IR (-O2):
%struct.instrument = type { i32 }
@.str = [6 x i8] c"local\00"
@.str.1 = [6 x i8] c"clear\00"
@.str.2 = [6 x i8] c"query\00"
@.str.5 = [6 x i8] c"write\00"
@.str.7 = [5 x i8] c"read\00"
@.str.8 = [2 x i8] c"?\00"
@.str.9 = [6 x i8] c"delay\00"
@.str.11 = [7 x i8] c"status\00"
@optarg = global i32 0
@.str.13 = [6 x i8] c"%hhu\0A\00"
@.str.14 = [5 x i8] c"help\00"
@str = [27 x i8] c"query requires an argument\00"
@str.16 = [27 x i8] c"write requires an argument\00"
@str.17 = [34 x i8] c"delay requires a seconds argument\00"
@str.18 = [32 x i8] c"status requires a mask argument\00"
@str.19 = [473 x i8] c"Command help:\0A <command> write gpib message <command>\0A <query?> write <command>, read response\0A quit/exit exit shell\0A clear send gpib clear command\0A local send gpib local command\0A status MASK read gpib status, exit if MASK matches\0A read/? read gpib message\0A write MESSAGE write gpib message\0A query MESSAGE write gpib message, then read\0A delay SEC delay SEC seconds\0A help dispaly this help\00"
define i32 @command(%struct.instrument* %0, i32 %1, i8** nocapture %2) {
%4 = alloca [4096 x i8]
%5 = alloca [4096 x i8]
%6 = alloca i8
%7 = alloca [4096 x i8]
%8 = load i8*, i8** %2
%9 = tail call i32 @strcmp(i8* dereferenceable(1) %8, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = tail call i32 @inst_loc(%struct.instrument* %0)
br label %109
13: ; preds = %3
%14 = tail call i32 @strcmp(i8* dereferenceable(1) %8, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = tail call i32 @inst_clr(%struct.instrument* %0, i32 100000)
br label %109
18: ; preds = %13
%19 = tail call i32 @strcmp(i8* dereferenceable(1) %8, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %32
21: ; preds = %18
%22 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%23 = icmp slt i32 %1, 2
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
br label %31
26: ; preds = %21
%27 = getelementptr inbounds i8*, i8** %2, i64 1
%28 = load i8*, i8** %27
%29 = call i32 @inst_qrystr(%struct.instrument* %0, i8* %28, i8* %22, i32 4096)
%30 = call i32 @puts(i8* %22)
br label %31
31: ; preds = %26, %24
br label %109
32: ; preds = %18
%33 = tail call i32 @strcmp(i8* dereferenceable(1) %8, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %43
35: ; preds = %32
%36 = icmp slt i32 %1, 2
br i1 %36, label %37, label %39
37: ; preds = %35
%38 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.16, i64 0, i64 0))
br label %109
39: ; preds = %35
%40 = getelementptr inbounds i8*, i8** %2, i64 1
%41 = load i8*, i8** %40
%42 = tail call i32 @inst_wrtstr(%struct.instrument* %0, i8* %41)
br label %109
43: ; preds = %32
%44 = tail call i32 @strcmp(i8* dereferenceable(1) %8, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%45 = icmp eq i32 %44, 0
br i1 %45, label %49, label %46
46: ; preds = %43
%47 = tail call i32 @strcmp(i8* dereferenceable(1) %8, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%48 = icmp eq i32 %47, 0
br i1 %48, label %49, label %53
49: ; preds = %46, %43
%50 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%51 = call i32 @inst_rdstr(%struct.instrument* %0, i8* %50, i32 4096)
%52 = call i32 @puts(i8* %50)
br label %109
53: ; preds = %46
%54 = tail call i32 @strcmp(i8* dereferenceable(1) %8, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%55 = icmp eq i32 %54, 0
br i1 %55, label %56, label %67
56: ; preds = %53
%57 = icmp slt i32 %1, 2
br i1 %57, label %58, label %60
58: ; preds = %56
%59 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.17, i64 0, i64 0))
br label %109
60: ; preds = %56
%61 = getelementptr inbounds i8*, i8** %2, i64 1
%62 = load i8*, i8** %61
%63 = tail call double @strtod(i8* nocapture %62, i32* null)
%64 = fmul double %63, 1.000000e+06
%65 = fptosi double %64 to i32
%66 = tail call i32 @usleep(i32 %65)
br label %109
67: ; preds = %53
%68 = tail call i32 @strcmp(i8* dereferenceable(1) %8, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
%69 = icmp eq i32 %68, 0
br i1 %69, label %70, label %89
70: ; preds = %67
%71 = icmp slt i32 %1, 2
br i1 %71, label %72, label %74
72: ; preds = %70
%73 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.18, i64 0, i64 0))
br label %88
74: ; preds = %70
%75 = load i32, i32* @optarg
%76 = tail call i64 @strtoul(i32 %75, i32* null, i32 0)
%77 = trunc i64 %76 to i32
%78 = call i32 @inst_rsp(%struct.instrument* %0, i8* %6)
%79 = load i8, i8* %6
%80 = zext i8 %79 to i32
%81 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0), i32 %80)
%82 = load i8, i8* %6
%83 = zext i8 %82 to i32
%84 = and i32 %83, %77
%85 = icmp eq i32 %84, 0
br i1 %85, label %88, label %86
86: ; preds = %74
%87 = call i32 @exit(i32 1)
unreachable
88: ; preds = %74, %72
br label %109
89: ; preds = %67
%90 = tail call i32 @strcmp(i8* dereferenceable(1) %8, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0))
%91 = icmp eq i32 %90, 0
br i1 %91, label %92, label %94
92: ; preds = %89
%93 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([473 x i8], [473 x i8]* @str.19, i64 0, i64 0))
br label %109
94: ; preds = %89
%95 = tail call i32 @strlen(i8* %8)
%96 = add nsw i32 %95, -1
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds i8, i8* %8, i64 %97
%99 = load i8, i8* %98
%100 = icmp eq i8 %99, 63
br i1 %100, label %101, label %106
101: ; preds = %94
%102 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%103 = load i8*, i8** %2
%104 = call i32 @inst_qrystr(%struct.instrument* %0, i8* %103, i8* %102, i32 4096)
%105 = call i32 @puts(i8* %102)
br label %109
106: ; preds = %94
%107 = load i8*, i8** %2
%108 = tail call i32 @inst_wrtstr(%struct.instrument* %0, i8* %107)
br label %109
109: ; preds = %58, %60, %37, %39, %16, %92, %106, %101, %88, %49, %31, %11
%110 = phi i32 [ 1, %101 ], [ 1, %106 ], [ 1, %92 ], [ 2, %88 ], [ 1, %49 ], [ 2, %31 ], [ 1, %16 ], [ 1, %11 ], [ 2, %39 ], [ 2, %37 ], [ 2, %60 ], [ 2, %58 ]
ret i32 %110
}