#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*/ int8_t;

/* Variables and functions */
int /*<<< orphan*/ STDOUT_FILENO;
scalar_t__ st_command(unsigned char *, int /*<<< orphan*/, int /*<<< orphan*/,
                      int /*<<< orphan*/);
int /*<<< orphan*/ strtol(char *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ write(int /*<<< orphan*/, unsigned char **, int);
int main(int argc, char *argv[]) {
  int8_t cmd, val = 0;
  int off = 0;
  unsigned char buf[32];
  if (argv[1])
    cmd = strtol(argv[1], NULL, 0);
  if (argv[2])
    val = strtol(argv[2], NULL, 0);
  buf[off++] = (0xAA);
  off += st_command(&buf[1], 0, cmd, val);
  write(STDOUT_FILENO, &buf, off);
}


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)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     1179 <main+0x49>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1050 <strtol@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x10(%rax)
je     119e <main+0x6e>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1050 <strtol@plt>
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x1c(%rbp)
cltq
movb   $0xaa,-0x40(%rbp,%rax,1)
lea    -0x40(%rbp),%rdi
add    $0x1,%rdi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
xor    %esi,%esi
call   1040 <st_command@plt>
mov    %rax,%rcx
movslq -0x1c(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x1c(%rbp)
mov    0x2e17(%rip),%rax
mov    (%rax),%edi
lea    -0x40(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <write@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
test   %rdi,%rdi
je     114f <main+0x1f>
xor    %esi,%esi
xor    %edx,%edx
call   1050 <strtol@plt>
mov    %eax,%ebp
jmp    114f <main+0x1f>
mov    0x10(%rbx),%rdi
test   %rdi,%rdi
je     1165 <main+0x35>
xor    %esi,%esi
xor    %edx,%edx
call   1050 <strtol@plt>
mov    %eax,%ecx
jmp    1167 <main+0x37>
xor    %ecx,%ecx
movb   $0xaa,(%rsp)
lea    0x1(%rsp),%rdi
xor    %esi,%esi
mov    %ebp,%edx
call   1040 <st_command@plt>
lea    0x1(%rax),%edx
mov    0x2e6d(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
call   1030 <write@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@STDOUT_FILENO = global i32 0
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 [32 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i32 0, i32* %8
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %19
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @strtol(i8* %17, i32* null, i32 0)
store i32 %18, i32* %6
br label %19
19: ; preds = %14, %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 2
%22 = load i8*, i8** %21
%23 = icmp ne i8* %22, null
br i1 %23, label %24, label %29
24: ; preds = %19
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = call i32 @strtol(i8* %27, i32* null, i32 0)
store i32 %28, i32* %7
br label %29
29: ; preds = %24, %19
%30 = load i32, i32* %8
%31 = add nsw i32 %30, 1
store i32 %31, i32* %8
%32 = sext i32 %30 to i64
%33 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 %32
store i8 -86, i8* %33
%34 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 1
%35 = load i32, i32* %6
%36 = load i32, i32* %7
%37 = call i64 @st_command(i8* %34, i32 0, i32 %35, i32 %36)
%38 = load i32, i32* %8
%39 = sext i32 %38 to i64
%40 = add nsw i64 %39, %37
%41 = trunc i64 %40 to i32
store i32 %41, i32* %8
%42 = load i32, i32* @STDOUT_FILENO
%43 = bitcast [32 x i8]* %9 to i8**
%44 = load i32, i32* %8
%45 = call i32 @write(i32 %42, i8** %43, i32 %44)
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
@STDOUT_FILENO = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [32 x i8]
%4 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = icmp eq i8* %6, null
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = tail call i32 @strtol(i8* nocapture %6, i32* null, i32 0)
br label %10
10: ; preds = %8, %2
%11 = phi i32 [ %9, %8 ], [ undef, %2 ]
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = icmp eq i8* %13, null
br i1 %14, label %17, label %15
15: ; preds = %10
%16 = tail call i32 @strtol(i8* nocapture %13, i32* null, i32 0)
br label %17
17: ; preds = %15, %10
%18 = phi i32 [ %16, %15 ], [ 0, %10 ]
store i8 -86, i8* %4
%19 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 1
%20 = call i64 @st_command(i8* %19, i32 0, i32 %11, i32 %18)
%21 = trunc i64 %20 to i32
%22 = add i32 %21, 1
%23 = load i32, i32* @STDOUT_FILENO
%24 = bitcast [32 x i8]* %3 to i8**
%25 = call i32 @write(i32 %23, i8** %24, i32 %22)
ret i32 0
}