#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_iters(int iterations[], long n) {
  int i, start_iter, stop_iter, which_thread;
  printf("\n");
  printf("Thread\t\tIterations\n");
  printf("------\t\t----------\n");
  which_thread = iterations[0];
  start_iter = stop_iter = 0;
  for (i = 0; i <= n; i++)
    if (iterations[i] == which_thread)
      stop_iter = i;
    else {
      printf("%4d  \t\t%d -- %d\n", which_thread, start_iter, stop_iter);
      which_thread = iterations[i];
      start_iter = stop_iter = i;
    }
  printf("%4d  \t\t%d -- %d\n", which_thread, start_iter, stop_iter);
}


x86 assembly (clang, -O0):
<Print_iters>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeff(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    -0x10(%rbp),%rax
jg     11d6 <Print_iters+0xc6>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x20(%rbp),%eax
jne    1195 <Print_iters+0x85>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11c3 <Print_iters+0xb3>
mov    -0x20(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    %eax,-0x18(%rbp)
jmp    11c8 <Print_iters+0xb8>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1168 <Print_iters+0x58>
mov    -0x20(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Print_iters>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r12
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xec1(%rip),%rdi
call   1040 <puts@plt>
lea    0xec8(%rip),%rdi
call   1040 <puts@plt>
mov    (%r12),%esi
test   %r14,%r14
js     11d2 <Print_iters+0xa2>
mov    $0x1,%ebx
lea    0xe8a(%rip),%r15
xor    %r13d,%r13d
mov    %esi,%eax
xor    %ecx,%ecx
xor    %edx,%edx
cmp    %eax,%esi
jne    11a0 <Print_iters+0x70>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    -0x1(%rbx),%ecx
mov    %esi,%eax
cmp    %r14,%rbx
jle    11bc <Print_iters+0x8c>
jmp    11ce <Print_iters+0x9e>
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    -0x4(%r12,%rbx,4),%eax
lea    -0x1(%rbx),%edx
mov    %r13d,%ecx
cmp    %r14,%rbx
jg     11ce <Print_iters+0x9e>
mov    (%r12,%rbx,4),%esi
add    $0x1,%rbx
add    $0x1,%r13
cmp    %eax,%esi
jne    11a0 <Print_iters+0x70>
jmp    1190 <Print_iters+0x60>
mov    %eax,%esi
jmp    11d6 <Print_iters+0xa6>
xor    %edx,%edx
xor    %ecx,%ecx
lea    0xe23(%rip),%rdi
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1050 <printf@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [20 x i8] c"Thread\09\09Iterations\0A\00"
@.str.2 = [20 x i8] c"------\09\09----------\0A\00"
@.str.3 = [17 x i8] c"%4d \09\09%d -- %d\0A\00"
define void @Print_iters(i32* %0, i64 %1) {
%3 = alloca i32*
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %3
store i64 %1, i64* %4
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%12 = load i32*, i32** %3
%13 = getelementptr inbounds i32, i32* %12, i64 0
%14 = load i32, i32* %13
store i32 %14, i32* %8
store i32 0, i32* %7
store i32 0, i32* %6
store i32 0, i32* %5
br label %15
15: ; preds = %42, %2
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = load i64, i64* %4
%19 = icmp sle i64 %17, %18
br i1 %19, label %20, label %45
20: ; preds = %15
%21 = load i32*, i32** %3
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
%25 = load i32, i32* %24
%26 = load i32, i32* %8
%27 = icmp eq i32 %25, %26
br i1 %27, label %28, label %30
28: ; preds = %20
%29 = load i32, i32* %5
store i32 %29, i32* %7
br label %41
30: ; preds = %20
%31 = load i32, i32* %8
%32 = load i32, i32* %6
%33 = load i32, i32* %7
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %31, i32 %32, i32 %33)
%35 = load i32*, i32** %3
%36 = load i32, i32* %5
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i32, i32* %35, i64 %37
%39 = load i32, i32* %38
store i32 %39, i32* %8
%40 = load i32, i32* %5
store i32 %40, i32* %7
store i32 %40, i32* %6
br label %41
41: ; preds = %30, %28
br label %42
42: ; preds = %41
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 1
store i32 %44, i32* %5
br label %15
45: ; preds = %15
%46 = load i32, i32* %8
%47 = load i32, i32* %6
%48 = load i32, i32* %7
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %46, i32 %47, i32 %48)
ret void
}

LLVM IR (-O2):
@.str.3 = [17 x i8] c"%4d \09\09%d -- %d\0A\00"
@str = [19 x i8] c"Thread\09\09Iterations\00"
@str.4 = [19 x i8] c"------\09\09----------\00"
define void @Print_iters(i32* nocapture %0, i64 %1) {
%3 = tail call i32 @putchar(i32 10)
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.4, i64 0, i64 0))
%6 = load i32, i32* %0
%7 = icmp slt i64 %1, 0
br i1 %7, label %31, label %8
8: ; preds = %2, %28
%9 = phi i32 [ %30, %28 ], [ %6, %2 ]
%10 = phi i64 [ %26, %28 ], [ 0, %2 ]
%11 = phi i32 [ %25, %28 ], [ %6, %2 ]
%12 = phi i32 [ %23, %28 ], [ 0, %2 ]
%13 = phi i32 [ %24, %28 ], [ 0, %2 ]
%14 = icmp eq i32 %9, %11
br i1 %14, label %15, label %17
15: ; preds = %8
%16 = trunc i64 %10 to i32
br label %22
17: ; preds = %8
%18 = getelementptr inbounds i32, i32* %0, i64 %10
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %11, i32 %13, i32 %12)
%20 = load i32, i32* %18
%21 = trunc i64 %10 to i32
br label %22
22: ; preds = %15, %17
%23 = phi i32 [ %16, %15 ], [ %21, %17 ]
%24 = phi i32 [ %13, %15 ], [ %21, %17 ]
%25 = phi i32 [ %9, %15 ], [ %20, %17 ]
%26 = add nuw i64 %10, 1
%27 = icmp sgt i64 %26, %1
br i1 %27, label %31, label %28
28: ; preds = %22
%29 = getelementptr inbounds i32, i32* %0, i64 %26
%30 = load i32, i32* %29
br label %8
31: ; preds = %22, %2
%32 = phi i32 [ 0, %2 ], [ %24, %22 ]
%33 = phi i32 [ 0, %2 ], [ %23, %22 ]
%34 = phi i32 [ %6, %2 ], [ %25, %22 ]
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %34, i32 %32, i32 %33)
ret void
}