#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*/ UpdateLineNumber(char *);
int /*<<< orphan*/ diagnostics(int, char *, char *);
int /*<<< orphan*/ free(char *);
char *getBraceParam();
char *getBracketParam();
int /*<<< orphan*/ newTheorem(char *, char *, char *, char *);
void CmdNewTheorem(int code) {
  char *name, *caption, *numbered_like, *within;
  name = getBraceParam();
  numbered_like = getBracketParam();
  caption = getBraceParam();
  within = getBracketParam();
  UpdateLineNumber(name);
  UpdateLineNumber(numbered_like);
  UpdateLineNumber(caption);
  UpdateLineNumber(within);
  diagnostics(2, "CmdNewTheorem name=<%s>", name);
  diagnostics(2, "CmdNewTheorem caption=<%s>", caption);
  diagnostics(2, "CmdNewTheorem like=<%s>",
              (numbered_like) ? numbered_like : "");
  newTheorem(name, caption, numbered_like, within);
  free(name);
  free(caption);
  if (numbered_like)
    free(numbered_like);
  if (within)
    free(within);
}


x86 assembly (clang, -O0):
<CmdNewTheorem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x0,%al
call   1040 <getBraceParam@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1070 <getBracketParam@plt>
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1040 <getBraceParam@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1070 <getBracketParam@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <UpdateLineNumber@plt>
mov    -0x20(%rbp),%rdi
call   1080 <UpdateLineNumber@plt>
mov    -0x18(%rbp),%rdi
call   1080 <UpdateLineNumber@plt>
mov    -0x28(%rbp),%rdi
call   1080 <UpdateLineNumber@plt>
mov    -0x10(%rbp),%rdx
mov    $0x2,%edi
lea    0xe35(%rip),%rsi
call   1050 <diagnostics@plt>
mov    -0x18(%rbp),%rdx
mov    $0x2,%edi
lea    0xe38(%rip),%rsi
call   1050 <diagnostics@plt>
cmpq   $0x0,-0x20(%rbp)
je     11fd <CmdNewTheorem+0x9d>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    120d <CmdNewTheorem+0xad>
lea    0xe46(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    120d <CmdNewTheorem+0xad>
mov    -0x30(%rbp),%rdx
mov    $0x2,%edi
lea    0xe16(%rip),%rsi
call   1050 <diagnostics@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1060 <newTheorem@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x20(%rbp)
je     125d <CmdNewTheorem+0xfd>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x28(%rbp)
je     1271 <CmdNewTheorem+0x111>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CmdNewTheorem>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <getBraceParam@plt>
mov    %rax,%r15
xor    %eax,%eax
call   1070 <getBracketParam@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1040 <getBraceParam@plt>
mov    %rax,%r12
xor    %eax,%eax
call   1070 <getBracketParam@plt>
mov    %rax,%r14
mov    %r15,%rdi
call   1080 <UpdateLineNumber@plt>
mov    %rbx,%rdi
call   1080 <UpdateLineNumber@plt>
mov    %r12,%rdi
call   1080 <UpdateLineNumber@plt>
mov    %r14,%rdi
call   1080 <UpdateLineNumber@plt>
lea    0xe49(%rip),%rsi
mov    $0x2,%edi
mov    %r15,%rdx
call   1050 <diagnostics@plt>
lea    0xe4d(%rip),%rsi
mov    $0x2,%edi
mov    %r12,%rdx
call   1050 <diagnostics@plt>
test   %rbx,%rbx
lea    0xe68(%rip),%rdx
cmovne %rbx,%rdx
lea    0xe46(%rip),%rsi
mov    $0x2,%edi
call   1050 <diagnostics@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1060 <newTheorem@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
test   %rbx,%rbx
je     1225 <CmdNewTheorem+0xc5>
mov    %rbx,%rdi
call   1030 <free@plt>
test   %r14,%r14
je     123d <CmdNewTheorem+0xdd>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <free@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [24 x i8] c"CmdNewTheorem name=<%s>\00"
@.str.1 = [27 x i8] c"CmdNewTheorem caption=<%s>\00"
@.str.2 = [24 x i8] c"CmdNewTheorem like=<%s>\00"
@.str.3 = [1 x i8] zeroinitializer
define void @CmdNewTheorem(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i32 %0, i32* %2
%7 = call i8* (...) @getBraceParam()
store i8* %7, i8** %3
%8 = call i8* (...) @getBracketParam()
store i8* %8, i8** %5
%9 = call i8* (...) @getBraceParam()
store i8* %9, i8** %4
%10 = call i8* (...) @getBracketParam()
store i8* %10, i8** %6
%11 = load i8*, i8** %3
%12 = call i32 @UpdateLineNumber(i8* %11)
%13 = load i8*, i8** %5
%14 = call i32 @UpdateLineNumber(i8* %13)
%15 = load i8*, i8** %4
%16 = call i32 @UpdateLineNumber(i8* %15)
%17 = load i8*, i8** %6
%18 = call i32 @UpdateLineNumber(i8* %17)
%19 = load i8*, i8** %3
%20 = call i32 @diagnostics(i32 2, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = load i8*, i8** %4
%22 = call i32 @diagnostics(i32 2, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%23 = load i8*, i8** %5
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %27
25: ; preds = %1
%26 = load i8*, i8** %5
br label %28
27: ; preds = %1
br label %28
28: ; preds = %27, %25
%29 = phi i8* [ %26, %25 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), %27 ]
%30 = call i32 @diagnostics(i32 2, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %29)
%31 = load i8*, i8** %3
%32 = load i8*, i8** %4
%33 = load i8*, i8** %5
%34 = load i8*, i8** %6
%35 = call i32 @newTheorem(i8* %31, i8* %32, i8* %33, i8* %34)
%36 = load i8*, i8** %3
%37 = call i32 @free(i8* %36)
%38 = load i8*, i8** %4
%39 = call i32 @free(i8* %38)
%40 = load i8*, i8** %5
%41 = icmp ne i8* %40, null
br i1 %41, label %42, label %45
42: ; preds = %28
%43 = load i8*, i8** %5
%44 = call i32 @free(i8* %43)
br label %45
45: ; preds = %42, %28
%46 = load i8*, i8** %6
%47 = icmp ne i8* %46, null
br i1 %47, label %48, label %51
48: ; preds = %45
%49 = load i8*, i8** %6
%50 = call i32 @free(i8* %49)
br label %51
51: ; preds = %48, %45
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c"CmdNewTheorem name=<%s>\00"
@.str.1 = [27 x i8] c"CmdNewTheorem caption=<%s>\00"
@.str.2 = [24 x i8] c"CmdNewTheorem like=<%s>\00"
@.str.3 = [1 x i8] zeroinitializer
define void @CmdNewTheorem(i32 %0) {
%2 = tail call i8* (...) @getBraceParam()
%3 = tail call i8* (...) @getBracketParam()
%4 = tail call i8* (...) @getBraceParam()
%5 = tail call i8* (...) @getBracketParam()
%6 = tail call i32 @UpdateLineNumber(i8* %2)
%7 = tail call i32 @UpdateLineNumber(i8* %3)
%8 = tail call i32 @UpdateLineNumber(i8* %4)
%9 = tail call i32 @UpdateLineNumber(i8* %5)
%10 = tail call i32 @diagnostics(i32 2, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %2)
%11 = tail call i32 @diagnostics(i32 2, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%12 = icmp eq i8* %3, null
%13 = select i1 %12, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* %3
%14 = tail call i32 @diagnostics(i32 2, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %13)
%15 = tail call i32 @newTheorem(i8* %2, i8* %4, i8* %3, i8* %5)
%16 = tail call i32 @free(i8* %2)
%17 = tail call i32 @free(i8* %4)
br i1 %12, label %20, label %18
18: ; preds = %1
%19 = tail call i32 @free(i8* %3)
br label %20
20: ; preds = %18, %1
%21 = icmp eq i8* %5, null
br i1 %21, label %24, label %22
22: ; preds = %20
%23 = tail call i32 @free(i8* %5)
br label %24
24: ; preds = %22, %20
ret void
}