#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*/ free(char *);
long get_num(char *, char *);
int /*<<< orphan*/ get_string(char *);
char *long2str(char *, long);
char *new_str(int /*<<< orphan*/);
long tt_setRemark(int, long, int /*<<< orphan*/, char *);
char *macttSetRemark(char *arg) {
  int tbl;
  long top;
  char *val;
  top = get_num("ttSetRemark", arg);
  tbl = (int)get_num("ttSetRemark", arg);
  val = new_str(get_string(arg));
  if ((top = tt_setRemark(tbl, top, get_string(arg), val)) < 0) {
    free(val);
    return long2str(arg, top);
  }
  *arg = '\0';
  return arg;
}


x86 assembly (clang, -O0):
<macttSetRemark>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe89(%rip),%rdi
call   1040 <get_num@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe75(%rip),%rdi
call   1040 <get_num@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <get_string@plt>
mov    %eax,%edi
call   1070 <new_str@plt>
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <get_string@plt>
mov    -0x34(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    %eax,%edx
mov    -0x28(%rbp),%rcx
call   1080 <tt_setRemark@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jge    11fd <macttSetRemark+0x9d>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <long2str@plt>
mov    %rax,-0x8(%rbp)
jmp    120c <macttSetRemark+0xac>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<macttSetRemark>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xe8e(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <get_num@plt>
mov    %rax,%r15
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <get_num@plt>
mov    %rax,%r12
mov    %rbx,%rdi
call   1050 <get_string@plt>
mov    %eax,%edi
call   1070 <new_str@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1050 <get_string@plt>
mov    %r12d,%edi
mov    %r15,%rsi
mov    %eax,%edx
mov    %r14,%rcx
call   1080 <tt_setRemark@plt>
test   %rax,%rax
js     11cf <macttSetRemark+0x6f>
movb   $0x0,(%rbx)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    %rax,%r15
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1060 <long2str@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"ttSetRemark\00"
define i8* @macttSetRemark(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i64
%6 = alloca i8*
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = call i64 @get_num(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %7)
store i64 %8, i64* %5
%9 = load i8*, i8** %3
%10 = call i64 @get_num(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = trunc i64 %10 to i32
store i32 %11, i32* %4
%12 = load i8*, i8** %3
%13 = call i32 @get_string(i8* %12)
%14 = call i8* @new_str(i32 %13)
store i8* %14, i8** %6
%15 = load i32, i32* %4
%16 = load i64, i64* %5
%17 = load i8*, i8** %3
%18 = call i32 @get_string(i8* %17)
%19 = load i8*, i8** %6
%20 = call i64 @tt_setRemark(i32 %15, i64 %16, i32 %18, i8* %19)
store i64 %20, i64* %5
%21 = icmp slt i64 %20, 0
br i1 %21, label %22, label %28
22: ; preds = %1
%23 = load i8*, i8** %6
%24 = call i32 @free(i8* %23)
%25 = load i8*, i8** %3
%26 = load i64, i64* %5
%27 = call i8* @long2str(i8* %25, i64 %26)
store i8* %27, i8** %2
br label %31
28: ; preds = %1
%29 = load i8*, i8** %3
store i8 0, i8* %29
%30 = load i8*, i8** %3
store i8* %30, i8** %2
br label %31
31: ; preds = %28, %22
%32 = load i8*, i8** %2
ret i8* %32
}

LLVM IR (-O2):
@.str = [12 x i8] c"ttSetRemark\00"
define i8* @macttSetRemark(i8* %0) {
%2 = tail call i64 @get_num(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %0)
%3 = tail call i64 @get_num(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %0)
%4 = trunc i64 %3 to i32
%5 = tail call i32 @get_string(i8* %0)
%6 = tail call i8* @new_str(i32 %5)
%7 = tail call i32 @get_string(i8* %0)
%8 = tail call i64 @tt_setRemark(i32 %4, i64 %2, i32 %7, i8* %6)
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = tail call i32 @free(i8* %6)
%12 = tail call i8* @long2str(i8* %0, i64 %8)
br label %14
13: ; preds = %1
store i8 0, i8* %0
br label %14
14: ; preds = %13, %10
%15 = phi i8* [ %12, %10 ], [ %0, %13 ]
ret i8* %15
}