#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 */
char *dec2hex(int, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
void construct_str(char *str, int loc_ctr, char *label, char *opcode,
                   char *operand) {
  char str2[50];
  strcpy(str, "");
  strcat(str, dec2hex(loc_ctr, str2));
  strcat(str, " ");
  strcat(str, label);
  if (strlen(label))
    strcat(str, " ");
  strcat(str, opcode);
  strcat(str, " ");
  strcat(str, operand);
  strcat(str, "\n");
}


x86 assembly (clang, -O0):
<construct_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe9d(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x60(%rbp),%rsi
call   1050 <dec2hex@plt>
mov    -0x68(%rbp),%rdi
mov    %rax,%rsi
call   1060 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    0xe6a(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%rax
je     11cb <construct_str+0x8b>
mov    -0x8(%rbp),%rdi
lea    0xe3a(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    0xe1d(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    0xe02(%rip),%rsi
call   1060 <strcat@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<construct_str>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x40,%rsp
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%r12
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xeb2(%rip),%rsi
call   1030 <strcpy@plt>
mov    %rsp,%rsi
mov    %ebp,%edi
call   1040 <dec2hex@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1050 <strcat@plt>
lea    0xe8e(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <strcat@plt>
cmpb   $0x0,(%r12)
je     119b <construct_str+0x6b>
lea    0xe6d(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <strcat@plt>
lea    0xe53(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strcat@plt>
lea    0xe3b(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c" \00"
@.str.2 = [2 x i8] c"\0A\00"
define void @construct_str(i8* %0, i32 %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca [50 x i8]
%7 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%8 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%9 = call i8* @dec2hex(i32 %1, i8* %7)
%10 = call i32 @strcat(i8* %0, i8* %9)
%11 = call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @strcat(i8* %0, i8* %2)
%13 = load i8, i8* %2
%14 = icmp eq i8 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %5
%16 = call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %15, %5
%18 = call i32 @strcat(i8* %0, i8* %3)
%19 = call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 @strcat(i8* %0, i8* %4)
%21 = call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}