#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 clickos_domid(char *);
int /*<<< orphan*/ clickos_write_handler(int, char *, char *, char *);
int /*<<< orphan*/ printf(char *, char *, char *, char *);
int strtol(char *, int /*<<< orphan*/ *, int);
int cmd_write_h(int argc, char **argv) {
  int domid;
  char *elem, *attr, *value;
  if (!(domid = strtol(argv[1], NULL, 10)))
    domid = clickos_domid(argv[1]);
  elem = argv[2];
  attr = argv[3];
  ;
  value = argv[4];
  clickos_write_handler(domid, elem, attr, value);
  printf("write(%s/%s, %s)\n", elem, attr, value);
  return 0;
}


x86 assembly (clang, -O0):
<cmd_write_h>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jne    1181 <cmd_write_h+0x41>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <clickos_domid@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
call   1030 <clickos_write_handler@plt>
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
lea    0xe34(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_write_h>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
test   %eax,%eax
jne    1165 <cmd_write_h+0x25>
mov    0x8(%rbx),%rdi
call   1060 <clickos_domid@plt>
mov    0x10(%rbx),%r14
mov    0x18(%rbx),%r15
mov    0x20(%rbx),%rbx
mov    %eax,%edi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
call   1030 <clickos_write_handler@plt>
lea    0xe78(%rip),%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [18 x i8] c"write(%s/%s, %s)\0A\00"
define i32 @cmd_write_h(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%9 = load i8**, i8*** %4
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i32 @strtol(i8* %11, i32* null, i32 10)
store i32 %12, i32* %5
%13 = icmp ne i32 %12, 0
br i1 %13, label %19, label %14
14: ; preds = %2
%15 = load i8**, i8*** %4
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @clickos_domid(i8* %17)
store i32 %18, i32* %5
br label %19
19: ; preds = %14, %2
%20 = load i8**, i8*** %4
%21 = getelementptr inbounds i8*, i8** %20, i64 2
%22 = load i8*, i8** %21
store i8* %22, i8** %6
%23 = load i8**, i8*** %4
%24 = getelementptr inbounds i8*, i8** %23, i64 3
%25 = load i8*, i8** %24
store i8* %25, i8** %7
%26 = load i8**, i8*** %4
%27 = getelementptr inbounds i8*, i8** %26, i64 4
%28 = load i8*, i8** %27
store i8* %28, i8** %8
%29 = load i32, i32* %5
%30 = load i8*, i8** %6
%31 = load i8*, i8** %7
%32 = load i8*, i8** %8
%33 = call i32 @clickos_write_handler(i32 %29, i8* %30, i8* %31, i8* %32)
%34 = load i8*, i8** %6
%35 = load i8*, i8** %7
%36 = load i8*, i8** %8
%37 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %34, i8* %35, i8* %36)
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"write(%s/%s, %s)\0A\00"
define i32 @cmd_write_h(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32 @strtol(i8* nocapture %4, i32* null, i32 10)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = load i8*, i8** %3
%9 = tail call i32 @clickos_domid(i8* %8)
br label %10
10: ; preds = %7, %2
%11 = phi i32 [ %5, %2 ], [ %9, %7 ]
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = getelementptr inbounds i8*, i8** %1, i64 3
%15 = load i8*, i8** %14
%16 = getelementptr inbounds i8*, i8** %1, i64 4
%17 = load i8*, i8** %16
%18 = tail call i32 @clickos_write_handler(i32 %11, i8* %13, i8* %15, i8* %17)
%19 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %13, i8* %15, i8* %17)
ret i32 0
}