#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 *);
char *get_arg_from_call(char const *, size_t *);
scalar_t__ hefesto_mloc(int);
char *infix2postfix(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
char *infix2postfix_function_args(const char *expr_args, const size_t esize) {
  char *e;
  char *iexpr, *pexpr;
  char *result = (char *)hefesto_mloc(8192);
  char *r;
  size_t offset = 1;
  iexpr = get_arg_from_call(expr_args, &offset);
  r = result;
  *r = '(';
  r++;
  while (*iexpr) {
    pexpr = infix2postfix(iexpr, strlen(iexpr), 0);
    for (e = pexpr; *e != 0; e++, r++)
      *r = *e;
    free(iexpr);
    free(pexpr);
    iexpr = get_arg_from_call(expr_args, &offset);
    if (*iexpr) {
      *r = ',';
      r++;
    }
  }
  free(iexpr);
  *r = 0;
  return result;
}


x86 assembly (clang, -O0):
<infix2postfix_function_args>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x2000,%edi
call   1060 <hefesto_mloc@plt>
mov    %rax,-0x30(%rbp)
movq   $0x1,-0x40(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1050 <get_arg_from_call@plt>
mov    %rax,-0x20(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movb   $0x28,(%rax)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     125a <infix2postfix_function_args+0x10a>
mov    -0x20(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x48(%rbp),%rdi
mov    %eax,%esi
xor    %edx,%edx
call   1070 <infix2postfix@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1212 <infix2postfix_function_args+0xc2>
mov    -0x18(%rbp),%rax
mov    (%rax),%cl
mov    -0x38(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    11d9 <infix2postfix_function_args+0x89>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1050 <get_arg_from_call@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     1255 <infix2postfix_function_args+0x105>
mov    -0x38(%rbp),%rax
movb   $0x2c,(%rax)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    11a2 <infix2postfix_function_args+0x52>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x30(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<infix2postfix_function_args>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
mov    $0x2000,%edi
call   1060 <hefesto_mloc@plt>
mov    %rax,%r14
movq   $0x1,(%rsp)
mov    %rsp,%rsi
mov    %r15,%rdi
call   1050 <get_arg_from_call@plt>
mov    %rax,%rbx
movb   $0x28,(%r14)
mov    %r14,%rbp
add    $0x1,%rbp
cmpb   $0x0,(%rax)
je     1212 <infix2postfix_function_args+0xc2>
mov    %rsp,%r12
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %edx,%edx
call   1070 <infix2postfix@plt>
mov    %rax,%r13
mov    (%rax),%al
test   %al,%al
je     11e2 <infix2postfix_function_args+0x92>
lea    0x1(%r13),%rcx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %al,0x0(%rbp)
add    $0x1,%rbp
movzbl (%rcx),%eax
add    $0x1,%rcx
test   %al,%al
jne    11d0 <infix2postfix_function_args+0x80>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <get_arg_from_call@plt>
mov    %rax,%rbx
cmpb   $0x0,(%rax)
je     1212 <infix2postfix_function_args+0xc2>
movb   $0x2c,0x0(%rbp)
add    $0x1,%rbp
cmpb   $0x0,(%rbx)
jne    11a0 <infix2postfix_function_args+0x50>
mov    %rbx,%rdi
call   1030 <free@plt>
movb   $0x0,0x0(%rbp)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @infix2postfix_function_args(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i64
store i8* %0, i8** %3
store i64 %1, i64* %4
%11 = call i64 @hefesto_mloc(i32 8192)
%12 = inttoptr i64 %11 to i8*
store i8* %12, i8** %8
store i64 1, i64* %10
%13 = load i8*, i8** %3
%14 = call i8* @get_arg_from_call(i8* %13, i64* %10)
store i8* %14, i8** %6
%15 = load i8*, i8** %8
store i8* %15, i8** %9
%16 = load i8*, i8** %9
store i8 40, i8* %16
%17 = load i8*, i8** %9
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %9
br label %19
19: ; preds = %57, %2
%20 = load i8*, i8** %6
%21 = load i8, i8* %20
%22 = icmp ne i8 %21, 0
br i1 %22, label %23, label %58
23: ; preds = %19
%24 = load i8*, i8** %6
%25 = load i8*, i8** %6
%26 = call i32 @strlen(i8* %25)
%27 = call i8* @infix2postfix(i8* %24, i32 %26, i32 0)
store i8* %27, i8** %7
%28 = load i8*, i8** %7
store i8* %28, i8** %5
br label %29
29: ; preds = %38, %23
%30 = load i8*, i8** %5
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %43
34: ; preds = %29
%35 = load i8*, i8** %5
%36 = load i8, i8* %35
%37 = load i8*, i8** %9
store i8 %36, i8* %37
br label %38
38: ; preds = %34
%39 = load i8*, i8** %5
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %5
%41 = load i8*, i8** %9
%42 = getelementptr inbounds i8, i8* %41, i32 1
store i8* %42, i8** %9
br label %29
43: ; preds = %29
%44 = load i8*, i8** %6
%45 = call i32 @free(i8* %44)
%46 = load i8*, i8** %7
%47 = call i32 @free(i8* %46)
%48 = load i8*, i8** %3
%49 = call i8* @get_arg_from_call(i8* %48, i64* %10)
store i8* %49, i8** %6
%50 = load i8*, i8** %6
%51 = load i8, i8* %50
%52 = icmp ne i8 %51, 0
br i1 %52, label %53, label %57
53: ; preds = %43
%54 = load i8*, i8** %9
store i8 44, i8* %54
%55 = load i8*, i8** %9
%56 = getelementptr inbounds i8, i8* %55, i32 1
store i8* %56, i8** %9
br label %57
57: ; preds = %53, %43
br label %19
58: ; preds = %19
%59 = load i8*, i8** %6
%60 = call i32 @free(i8* %59)
%61 = load i8*, i8** %9
store i8 0, i8* %61
%62 = load i8*, i8** %8
ret i8* %62
}

LLVM IR (-O2):
define i8* @infix2postfix_function_args(i8* %0, i64 %1) {
%3 = alloca i64
%4 = tail call i64 @hefesto_mloc(i32 8192)
%5 = inttoptr i64 %4 to i8*
%6 = bitcast i64* %3 to i8*
store i64 1, i64* %3
%7 = call i8* @get_arg_from_call(i8* %0, i64* %3)
store i8 40, i8* %5
%8 = getelementptr inbounds i8, i8* %5, i64 1
%9 = load i8, i8* %7
%10 = icmp eq i8 %9, 0
br i1 %10, label %37, label %11
11: ; preds = %2, %33
%12 = phi i8* [ %34, %33 ], [ %8, %2 ]
%13 = phi i8* [ %30, %33 ], [ %7, %2 ]
%14 = call i32 @strlen(i8* %13)
%15 = call i8* @infix2postfix(i8* %13, i32 %14, i32 0)
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 0
br i1 %17, label %26, label %18
18: ; preds = %11, %18
%19 = phi i8 [ %24, %18 ], [ %16, %11 ]
%20 = phi i8* [ %23, %18 ], [ %12, %11 ]
%21 = phi i8* [ %22, %18 ], [ %15, %11 ]
store i8 %19, i8* %20
%22 = getelementptr inbounds i8, i8* %21, i64 1
%23 = getelementptr inbounds i8, i8* %20, i64 1
%24 = load i8, i8* %22
%25 = icmp eq i8 %24, 0
br i1 %25, label %26, label %18
26: ; preds = %18, %11
%27 = phi i8* [ %12, %11 ], [ %23, %18 ]
%28 = call i32 @free(i8* %13)
%29 = call i32 @free(i8* %15)
%30 = call i8* @get_arg_from_call(i8* %0, i64* %3)
%31 = load i8, i8* %30
%32 = icmp eq i8 %31, 0
br i1 %32, label %37, label %33
33: ; preds = %26
store i8 44, i8* %27
%34 = getelementptr inbounds i8, i8* %27, i64 1
%35 = load i8, i8* %30
%36 = icmp eq i8 %35, 0
br i1 %36, label %37, label %11
37: ; preds = %26, %33, %2
%38 = phi i8* [ %7, %2 ], [ %30, %33 ], [ %30, %26 ]
%39 = phi i8* [ %8, %2 ], [ %27, %26 ], [ %34, %33 ]
%40 = call i32 @free(i8* %38)
store i8 0, i8* %39
ret i8* %5
}