#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 SerialAPI_request(unsigned char *, int);
unsigned char atoi(char *);
int ZW_ApplicationNodeInformation(unsigned devmask, unsigned char generic,
                                  unsigned char specific, int argc,
                                  char *argv[]) {
  unsigned char buf[255];
  int l = 6;
  buf[0] = 0x00;
  buf[1] = 0x3;
  buf[2] = devmask;
  buf[3] = generic;
  buf[4] = specific;
  buf[5] = 0;
  while (argc > 0) {
    buf[l] = atoi(*argv);
    argv++;
    l++;
    argc--;
  }
  buf[5] = l - 6;
  return SerialAPI_request(buf, l);
}


x86 assembly (clang, -O0):
<ZW_ApplicationNodeInformation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %dl,%al
mov    %sil,%dl
mov    %edi,-0x4(%rbp)
mov    %dl,-0x5(%rbp)
mov    %al,-0x6(%rbp)
mov    %ecx,-0xc(%rbp)
mov    %r8,-0x18(%rbp)
movl   $0x6,-0x124(%rbp)
movb   $0x0,-0x120(%rbp)
movb   $0x3,-0x11f(%rbp)
mov    -0x4(%rbp),%eax
mov    %al,-0x11e(%rbp)
mov    -0x5(%rbp),%al
mov    %al,-0x11d(%rbp)
mov    -0x6(%rbp),%al
mov    %al,-0x11c(%rbp)
movb   $0x0,-0x11b(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    11c9 <ZW_ApplicationNodeInformation+0xa9>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1040 <atoi@plt>
mov    %al,%cl
movslq -0x124(%rbp),%rax
mov    %cl,-0x120(%rbp,%rax,1)
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
mov    -0x124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x124(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    117a <ZW_ApplicationNodeInformation+0x5a>
mov    -0x124(%rbp),%eax
sub    $0x6,%eax
mov    %al,-0x11b(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x124(%rbp),%esi
call   1030 <SerialAPI_request@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ZW_ApplicationNodeInformation>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x108,%rsp
movw   $0x300,(%rsp)
mov    %dil,0x2(%rsp)
mov    %sil,0x3(%rsp)
mov    %dl,0x4(%rsp)
test   %ecx,%ecx
jle    1178 <ZW_ApplicationNodeInformation+0x58>
mov    %r8,%r15
mov    %ecx,%r14d
mov    %ecx,%r12d
add    $0x6,%r14d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r15,%rbx,8),%rdi
call   1040 <atoi@plt>
mov    %al,0x6(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1160 <ZW_ApplicationNodeInformation+0x40>
jmp    117e <ZW_ApplicationNodeInformation+0x5e>
mov    $0x6,%r14d
lea    -0x6(%r14),%eax
mov    %al,0x5(%rsp)
mov    %rsp,%rdi
mov    %r14d,%esi
call   1030 <SerialAPI_request@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @ZW_ApplicationNodeInformation(i32 %0, i8 zeroext %1, i8 zeroext %2, i32 %3, i8** %4) {
%6 = alloca i32
%7 = alloca i8
%8 = alloca i8
%9 = alloca i32
%10 = alloca i8**
%11 = alloca [255 x i8]
%12 = alloca i32
store i32 %0, i32* %6
store i8 %1, i8* %7
store i8 %2, i8* %8
store i32 %3, i32* %9
store i8** %4, i8*** %10
store i32 6, i32* %12
%13 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 0
store i8 0, i8* %13
%14 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 1
store i8 3, i8* %14
%15 = load i32, i32* %6
%16 = trunc i32 %15 to i8
%17 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 2
store i8 %16, i8* %17
%18 = load i8, i8* %7
%19 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 3
store i8 %18, i8* %19
%20 = load i8, i8* %8
%21 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 4
store i8 %20, i8* %21
%22 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 5
store i8 0, i8* %22
br label %23
23: ; preds = %26, %5
%24 = load i32, i32* %9
%25 = icmp sgt i32 %24, 0
br i1 %25, label %26, label %39
26: ; preds = %23
%27 = load i8**, i8*** %10
%28 = load i8*, i8** %27
%29 = call zeroext i8 @atoi(i8* %28)
%30 = load i32, i32* %12
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 %31
store i8 %29, i8* %32
%33 = load i8**, i8*** %10
%34 = getelementptr inbounds i8*, i8** %33, i32 1
store i8** %34, i8*** %10
%35 = load i32, i32* %12
%36 = add nsw i32 %35, 1
store i32 %36, i32* %12
%37 = load i32, i32* %9
%38 = add nsw i32 %37, -1
store i32 %38, i32* %9
br label %23
39: ; preds = %23
%40 = load i32, i32* %12
%41 = sub nsw i32 %40, 6
%42 = trunc i32 %41 to i8
%43 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 5
store i8 %42, i8* %43
%44 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 0
%45 = load i32, i32* %12
%46 = call i32 @SerialAPI_request(i8* %44, i32 %45)
ret i32 %46
}

LLVM IR (-O2):
define i32 @ZW_ApplicationNodeInformation(i32 %0, i8 zeroext %1, i8 zeroext %2, i32 %3, i8** nocapture %4) {
%6 = alloca [255 x i8]
%7 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
store i8 0, i8* %7
%8 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 1
store i8 3, i8* %8
%9 = trunc i32 %0 to i8
%10 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 2
store i8 %9, i8* %10
%11 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 3
store i8 %1, i8* %11
%12 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 4
store i8 %2, i8* %12
%13 = icmp sgt i32 %3, 0
br i1 %13, label %14, label %26
14: ; preds = %5
%15 = add nuw i32 %3, 6
%16 = zext i32 %15 to i64
br label %17
17: ; preds = %14, %17
%18 = phi i64 [ 6, %14 ], [ %24, %17 ]
%19 = phi i8** [ %4, %14 ], [ %23, %17 ]
%20 = load i8*, i8** %19
%21 = tail call zeroext i8 @atoi(i8* %20)
%22 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 %18
store i8 %21, i8* %22
%23 = getelementptr inbounds i8*, i8** %19, i64 1
%24 = add nuw nsw i64 %18, 1
%25 = icmp eq i64 %24, %16
br i1 %25, label %26, label %17
26: ; preds = %17, %5
%27 = phi i32 [ 6, %5 ], [ %15, %17 ]
%28 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 5
%29 = trunc i32 %27 to i8
%30 = add i8 %29, -6
store i8 %30, i8* %28
%31 = call i32 @SerialAPI_request(i8* %7, i32 %27)
ret i32 %31
}