#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*/ printf(char *, ...);
void print(int n) {
  int i;
  printf("#define T%d(t", n);
  for (i = 0; i < (n - 1) / 2; i++)
    printf(",t%d,x%d", i, i);
  printf(") \\\n");
  printf("  do { \\\n");
  printf("    if (T_ACTIVE(t)) { \\\n");
  printf("      T_LOCAL_DATA \\\n");
  printf("      T_HEADER(t); \\\n");
  for (i = 0; i < (n - 1) / 2; i++)
    printf("      T_PUT_##t%d(%d, x%d); \\\n", i, i + 2, i);
  printf("      T_COMMIT(); \\\n");
  printf("    } \\\n");
  printf("  } while (0)\n");
  printf("\n");
}


x86 assembly (clang, -O0):
<print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xedb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
cmp    %ecx,%eax
jge    1176 <print+0x66>
mov    -0x8(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1133 <print+0x23>
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
cmp    %ecx,%eax
jge    120c <print+0xfc>
mov    -0x8(%rbp),%esi
mov    -0x8(%rbp),%edx
add    $0x2,%edx
mov    -0x8(%rbp),%ecx
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11c3 <print+0xb3>
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%r14d
lea    0xebe(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x3,%r14d
jl     120a <print+0xda>
lea    -0x1(%r14),%eax
shr    $0x1f,%eax
lea    (%r14,%rax,1),%r15d
add    $0xffffffff,%r15d
sar    %r15d
cmp    $0x2,%r15d
mov    $0x1,%ebx
cmovge %r15d,%ebx
lea    0xe92(%rip),%r12
xor    %ebp,%ebp
xchg   %ax,%ax
mov    %r12,%rdi
mov    %ebp,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebp
cmp    %ebp,%ebx
jne    1180 <print+0x50>
lea    0xe9a(%rip),%rdi
call   1040 <puts@plt>
lea    0xe92(%rip),%rdi
call   1040 <puts@plt>
lea    0xe8f(%rip),%rdi
call   1040 <puts@plt>
lea    0xe9c(%rip),%rdi
call   1040 <puts@plt>
lea    0xea5(%rip),%rdi
call   1040 <puts@plt>
cmp    $0x3,%r14d
jl     1246 <print+0x116>
cmp    $0x2,%r15d
mov    $0x1,%ebp
cmovge %r15d,%ebp
lea    0xe2c(%rip),%r14
xor    %ebx,%ebx
nopl   (%rax)
lea    0x2(%rbx),%edx
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebx,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebx
cmp    %ebp,%ebx
jne    11f0 <print+0xc0>
jmp    1246 <print+0x116>
lea    0xe25(%rip),%rdi
call   1040 <puts@plt>
lea    0xe1d(%rip),%rdi
call   1040 <puts@plt>
lea    0xe1a(%rip),%rdi
call   1040 <puts@plt>
lea    0xe27(%rip),%rdi
call   1040 <puts@plt>
lea    0xe30(%rip),%rdi
call   1040 <puts@plt>
lea    0xe39(%rip),%rdi
call   1040 <puts@plt>
lea    0xe41(%rip),%rdi
call   1040 <puts@plt>
lea    0xe3d(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"#define T%d(t\00"
@.str.1 = [9 x i8] c",t%d,x%d\00"
@.str.2 = [5 x i8] c") \\\0A\00"
@.str.3 = [10 x i8] c" do { \\\0A\00"
@.str.4 = [26 x i8] c" if (T_ACTIVE(t)) { \\\0A\00"
@.str.5 = [22 x i8] c" T_LOCAL_DATA \\\0A\00"
@.str.6 = [22 x i8] c" T_HEADER(t); \\\0A\00"
@.str.7 = [31 x i8] c" T_PUT_##t%d(%d, x%d); \\\0A\00"
@.str.8 = [21 x i8] c" T_COMMIT(); \\\0A\00"
@.str.9 = [9 x i8] c" } \\\0A\00"
@.str.10 = [15 x i8] c" } while (0)\0A\00"
@.str.11 = [2 x i8] c"\0A\00"
define void @print(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %4)
store i32 0, i32* %3
br label %6
6: ; preds = %16, %1
%7 = load i32, i32* %3
%8 = load i32, i32* %2
%9 = sub nsw i32 %8, 1
%10 = sdiv i32 %9, 2
%11 = icmp slt i32 %7, %10
br i1 %11, label %12, label %19
12: ; preds = %6
%13 = load i32, i32* %3
%14 = load i32, i32* %3
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %13, i32 %14)
br label %16
16: ; preds = %12
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
br label %6
19: ; preds = %6
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %3
br label %25
25: ; preds = %37, %19
%26 = load i32, i32* %3
%27 = load i32, i32* %2
%28 = sub nsw i32 %27, 1
%29 = sdiv i32 %28, 2
%30 = icmp slt i32 %26, %29
br i1 %30, label %31, label %40
31: ; preds = %25
%32 = load i32, i32* %3
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 2
%35 = load i32, i32* %3
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i32 %32, i32 %34, i32 %35)
br label %37
37: ; preds = %31
%38 = load i32, i32* %3
%39 = add nsw i32 %38, 1
store i32 %39, i32* %3
br label %25
40: ; preds = %25
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0))
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0))
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"#define T%d(t\00"
@.str.1 = [9 x i8] c",t%d,x%d\00"
@.str.7 = [31 x i8] c" T_PUT_##t%d(%d, x%d); \\\0A\00"
@str = [4 x i8] c") \\\00"
@str.12 = [9 x i8] c" do { \\\00"
@str.13 = [25 x i8] c" if (T_ACTIVE(t)) { \\\00"
@str.14 = [21 x i8] c" T_LOCAL_DATA \\\00"
@str.15 = [21 x i8] c" T_HEADER(t); \\\00"
@str.16 = [20 x i8] c" T_COMMIT(); \\\00"
@str.17 = [8 x i8] c" } \\\00"
@str.18 = [14 x i8] c" } while (0)\00"
define void @print(i32 %0) {
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %0)
%3 = add nsw i32 %0, -1
%4 = sdiv i32 %3, 2
%5 = icmp sgt i32 %0, 2
br i1 %5, label %6, label %27
6: ; preds = %1
%7 = call i32 @llvm.smax.i32(i32 %4, i32 1)
br label %8
8: ; preds = %6, %8
%9 = phi i32 [ %11, %8 ], [ 0, %6 ]
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %9, i32 %9)
%11 = add nuw nsw i32 %9, 1
%12 = icmp eq i32 %11, %7
br i1 %12, label %13, label %8
13: ; preds = %8
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.12, i64 0, i64 0))
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.13, i64 0, i64 0))
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.14, i64 0, i64 0))
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.15, i64 0, i64 0))
br i1 %5, label %19, label %33
19: ; preds = %13
%20 = call i32 @llvm.smax.i32(i32 %4, i32 1)
br label %21
21: ; preds = %19, %21
%22 = phi i32 [ %25, %21 ], [ 0, %19 ]
%23 = add nuw nsw i32 %22, 2
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i32 %22, i32 %23, i32 %22)
%25 = add nuw nsw i32 %22, 1
%26 = icmp eq i32 %25, %20
br i1 %26, label %33, label %21
27: ; preds = %1
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.12, i64 0, i64 0))
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.13, i64 0, i64 0))
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.14, i64 0, i64 0))
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.15, i64 0, i64 0))
br label %33
33: ; preds = %21, %27, %13
%34 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.16, i64 0, i64 0))
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.17, i64 0, i64 0))
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.18, i64 0, i64 0))
%37 = tail call i32 @putchar(i32 10)
ret void
}