#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*/ exit(int);
int flon_dispatch(char *);
char *flon_generate_exid(char *);
char *flu_sprintf(char *, char *);
int flu_writeall(char *, char *, char *, char *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ perror(char *);
void hlp_start_execution(char *domain) {
  char *exid = flon_generate_exid(domain);
  char *name = flu_sprintf("exe_%s.json", exid);
  int r = flu_writeall("var/spool/dis/%s", name,
                       "{"
                       "point: execute\n"
                       "tree: [ invoke { _0: \"null\" } [] ]\n"
                       "exid: %s\n"
                       "payload: {\n"
                       "hello: %s\n"
                       "}\n"
                       "}",
                       exid, domain);
  if (r != 1) {
    perror("failed to write exe_ file");
    exit(1);
  }
  r = flon_dispatch(name);
  if (r != 2) {
    perror("failed to dispatch exe_ file");
    exit(2);
  }
  free(exid);
  free(name);
}


x86 assembly (clang, -O0):
<hlp_start_execution>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <flon_generate_exid@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe6c(%rip),%rdi
call   1050 <flu_sprintf@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%r8
lea    0xe5c(%rip),%rdi
lea    0xe66(%rip),%rdx
call   1070 <flu_writeall@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
je     11df <hlp_start_execution+0x6f>
lea    0xea2(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1040 <flon_dispatch@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x2,-0x1c(%rbp)
je     120b <hlp_start_execution+0x9b>
lea    0xe90(%rip),%rdi
call   1080 <perror@plt>
mov    $0x2,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hlp_start_execution>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
call   1060 <flon_generate_exid@plt>
mov    %rax,%r14
lea    0xe79(%rip),%rdi
mov    %rax,%rsi
call   1050 <flu_sprintf@plt>
mov    %rax,%rbx
lea    0xe73(%rip),%rdi
lea    0xe7d(%rip),%rdx
mov    %rax,%rsi
mov    %r14,%rcx
mov    %r15,%r8
call   1070 <flu_writeall@plt>
cmp    $0x1,%eax
jne    11d5 <hlp_start_execution+0x65>
mov    %rbx,%rdi
call   1040 <flon_dispatch@plt>
cmp    $0x2,%eax
jne    11eb <hlp_start_execution+0x7b>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <free@plt>
lea    0xe96(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
lea    0xe9a(%rip),%rdi
call   1080 <perror@plt>
mov    $0x2,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"exe_%s.json\00"
@.str.1 = [17 x i8] c"var/spool/dis/%s\00"
@.str.2 = [85 x i8] c"{point: execute\0Atree: [ invoke { _0: \22null\22 } [] ]\0Aexid: %s\0Apayload: {\0Ahello: %s\0A}\0A}\00"
@.str.3 = [26 x i8] c"failed to write exe_ file\00"
@.str.4 = [29 x i8] c"failed to dispatch exe_ file\00"
define void @hlp_start_execution(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i8* @flon_generate_exid(i8* %6)
store i8* %7, i8** %3
%8 = load i8*, i8** %3
%9 = call i8* @flu_sprintf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %8)
store i8* %9, i8** %4
%10 = load i8*, i8** %4
%11 = load i8*, i8** %3
%12 = load i8*, i8** %2
%13 = call i32 @flu_writeall(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %10, i8* getelementptr inbounds ([85 x i8], [85 x i8]* @.str.2, i64 0, i64 0), i8* %11, i8* %12)
store i32 %13, i32* %5
%14 = load i32, i32* %5
%15 = icmp ne i32 %14, 1
br i1 %15, label %16, label %19
16: ; preds = %1
%17 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %1
%20 = load i8*, i8** %4
%21 = call i32 @flon_dispatch(i8* %20)
store i32 %21, i32* %5
%22 = load i32, i32* %5
%23 = icmp ne i32 %22, 2
br i1 %23, label %24, label %27
24: ; preds = %19
%25 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
%26 = call i32 @exit(i32 2)
unreachable
27: ; preds = %19
%28 = load i8*, i8** %3
%29 = call i32 @free(i8* %28)
%30 = load i8*, i8** %4
%31 = call i32 @free(i8* %30)
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"exe_%s.json\00"
@.str.1 = [17 x i8] c"var/spool/dis/%s\00"
@.str.2 = [85 x i8] c"{point: execute\0Atree: [ invoke { _0: \22null\22 } [] ]\0Aexid: %s\0Apayload: {\0Ahello: %s\0A}\0A}\00"
@.str.3 = [26 x i8] c"failed to write exe_ file\00"
@.str.4 = [29 x i8] c"failed to dispatch exe_ file\00"
define void @hlp_start_execution(i8* %0) {
%2 = tail call i8* @flon_generate_exid(i8* %0)
%3 = tail call i8* @flu_sprintf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = tail call i32 @flu_writeall(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %3, i8* getelementptr inbounds ([85 x i8], [85 x i8]* @.str.2, i64 0, i64 0), i8* %2, i8* %0)
%5 = icmp eq i32 %4, 1
br i1 %5, label %9, label %6
6: ; preds = %1
%7 = tail call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %1
%10 = tail call i32 @flon_dispatch(i8* %3)
%11 = icmp eq i32 %10, 2
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = tail call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
%14 = tail call i32 @exit(i32 2)
unreachable
15: ; preds = %9
%16 = tail call i32 @free(i8* %2)
%17 = tail call i32 @free(i8* %3)
ret void
}