#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 remove(char const *);
int /*<<< orphan*/ snprintf(char *, int, char *, char const *, char const *);
int system(char *);
int assemble(int mode, const char *as_file, const char *obj_file) {
  if (!(mode & (1 << 1)) || mode & (1 << 3))
    return 0;
  char buf[256];
  snprintf(buf, 256, "as %s -g -o %s", as_file, obj_file);
  int ret = system(buf);
  if (ret == 0 && !(mode & (1 << 2))) {
    ret = remove(as_file);
  }
  return ret;
}


x86 assembly (clang, -O0):
<assemble>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     1164 <assemble+0x34>
mov    -0x8(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     1170 <assemble+0x40>
movl   $0x0,-0x4(%rbp)
jmp    11d6 <assemble+0xa6>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    $0x100,%esi
lea    0xe75(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x120(%rbp),%rdi
call   1040 <system@plt>
mov    %eax,-0x124(%rbp)
cmpl   $0x0,-0x124(%rbp)
jne    11cd <assemble+0x9d>
mov    -0x8(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
jne    11cd <assemble+0x9d>
mov    -0x10(%rbp),%rdi
call   1030 <remove@plt>
mov    %eax,-0x124(%rbp)
mov    -0x124(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<assemble>:
mov    %edi,%ecx
and    $0xa,%ecx
xor    %eax,%eax
cmp    $0x2,%ecx
jne    1190 <assemble+0x60>
push   %rbp
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %rdx,%r8
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xeaa(%rip),%rdx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x100,%esi
mov    %rbx,%rcx
call   1050 <snprintf@plt>
mov    %r14,%rdi
call   1040 <system@plt>
test   %eax,%eax
jne    1185 <assemble+0x55>
xor    %eax,%eax
test   $0x4,%bpl
jne    1185 <assemble+0x55>
mov    %rbx,%rdi
call   1030 <remove@plt>
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [15 x i8] c"as %s -g -o %s\00"
define i32 @assemble(i32 %0, i8* %1, i8* %2) {
%4 = alloca [256 x i8]
%5 = and i32 %0, 10
%6 = icmp eq i32 %5, 2
br i1 %6, label %7, label %19
7: ; preds = %3
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%9 = call i32 @snprintf(i8* %8, i32 256, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %2)
%10 = call i32 @system(i8* %8)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %7
%13 = and i32 %0, 4
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = call i32 @remove(i8* %1)
br label %17
17: ; preds = %15, %12, %7
%18 = phi i32 [ 0, %12 ], [ %16, %15 ], [ %10, %7 ]
br label %19
19: ; preds = %3, %17
%20 = phi i32 [ %18, %17 ], [ 0, %3 ]
ret i32 %20
}