#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 *add(char *, char *);
int /*<<< orphan*/ printf(char *, char *, ...);
char *subtractone(char *);
void printTWNchain(char *primeorigin, int primelength) {
  if (primelength <= 0) {
    return;
  }
  printTWNchain(add(primeorigin, primeorigin), primelength - 2);
  if (primelength > 1) {
    printf("%s,%s,", add(primeorigin, "1"), subtractone(primeorigin));
  } else {
    printf("%s,", subtractone(primeorigin));
  }
}


x86 assembly (clang, -O0):
<printTWNchain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jg     115e <printTWNchain+0x1e>
jmp    11d4 <printTWNchain+0x94>
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <add@plt>
mov    %rax,%rdi
mov    -0xc(%rbp),%esi
sub    $0x2,%esi
call   1060 <printTWNchain@plt>
cmpl   $0x1,-0xc(%rbp)
jle    11ba <printTWNchain+0x7a>
mov    -0x8(%rbp),%rdi
lea    0xe79(%rip),%rsi
call   1030 <add@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <subtractone@plt>
mov    -0x18(%rbp),%rsi
mov    %rax,%rdx
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11d4 <printTWNchain+0x94>
mov    -0x8(%rbp),%rdi
call   1040 <subtractone@plt>
mov    %rax,%rsi
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printTWNchain>:
push   %r14
push   %rbx
push   %rax
test   %esi,%esi
jle    1185 <printTWNchain+0x45>
mov    %esi,%ebx
mov    %rdi,%r14
mov    %rdi,%rsi
call   1030 <add@plt>
lea    -0x2(%rbx),%esi
mov    %rax,%rdi
call   1060 <printTWNchain@plt>
cmp    $0x1,%ebx
jne    118d <printTWNchain+0x4d>
mov    %r14,%rdi
call   1040 <subtractone@plt>
lea    0xe8f(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe73(%rip),%rsi
mov    %r14,%rdi
call   1030 <add@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1040 <subtractone@plt>
lea    0xe52(%rip),%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <printf@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"%s,%s,\00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [4 x i8] c"%s,\00"
define void @printTWNchain(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = icmp sle i32 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %2
br label %26
8: ; preds = %2
%9 = load i8*, i8** %3
%10 = load i8*, i8** %3
%11 = call i8* @add(i8* %9, i8* %10)
%12 = load i32, i32* %4
%13 = sub nsw i32 %12, 2
%14 = load i32, i32* %4
%15 = icmp sgt i32 %14, 1
br i1 %15, label %16, label %22
16: ; preds = %8
%17 = load i8*, i8** %3
%18 = call i8* @add(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%19 = load i8*, i8** %3
%20 = call i8* @subtractone(i8* %19)
%21 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %18, i8* %20)
br label %26
22: ; preds = %8
%23 = load i8*, i8** %3
%24 = call i8* @subtractone(i8* %23)
%25 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %24)
br label %26
26: ; preds = %7, %22, %16
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"%s,%s,\00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [4 x i8] c"%s,\00"
define void @printTWNchain(i8* %0, i32 %1) {
%3 = icmp slt i32 %1, 1
br i1 %3, label %15, label %4
4: ; preds = %2
%5 = tail call i8* @add(i8* %0, i8* %0)
%6 = add nsw i32 %1, -2
tail call void @printTWNchain(i8* %5, i32 %6)
%7 = icmp eq i32 %1, 1
br i1 %7, label %12, label %8
8: ; preds = %4
%9 = tail call i8* @add(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i8* @subtractone(i8* %0)
%11 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %9, i8* %10)
br label %15
12: ; preds = %4
%13 = tail call i8* @subtractone(i8* %0)
%14 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %13)
br label %15
15: ; preds = %2, %12, %8
ret void
}