#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_comm_schedule(int **sched, int npes) {
  int pe, i, width;
  if (npes < 10)
    width = 1;
  else if (npes < 100)
    width = 2;
  else
    width = 3;
  for (pe = 0; pe < npes; ++pe) {
    printf("pe %*d schedule:", width, pe);
    for (i = 0; sched[pe][i] != -1; ++i)
      printf("  %*d", width, sched[pe][i]);
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<print_comm_schedule>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    1135 <print_comm_schedule+0x25>
movl   $0x1,-0x18(%rbp)
jmp    1157 <print_comm_schedule+0x47>
cmpl   $0x64,-0xc(%rbp)
jge    114b <print_comm_schedule+0x3b>
movl   $0x2,-0x18(%rbp)
jmp    1152 <print_comm_schedule+0x42>
movl   $0x3,-0x18(%rbp)
jmp    1157 <print_comm_schedule+0x47>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ed <print_comm_schedule+0xdd>
mov    -0x18(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x14(%rbp),%rcx
cmpl   $0xffffffff,(%rax,%rcx,4)
je     11d1 <print_comm_schedule+0xc1>
mov    -0x18(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1185 <print_comm_schedule+0x75>
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    115e <print_comm_schedule+0x4e>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_comm_schedule>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
cmp    $0x64,%esi
setl   %al
xor    $0x3,%eax
cmp    $0xa,%esi
mov    $0x1,%ebp
cmovge %eax,%ebp
test   %esi,%esi
jle    11bf <print_comm_schedule+0x9f>
mov    %rdi,%r12
mov    %esi,%r13d
lea    0xebf(%rip),%r15
xor    %ebx,%ebx
jmp    1173 <print_comm_schedule+0x53>
cs nopw 0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %r13,%rbx
je     11bf <print_comm_schedule+0x9f>
lea    0xe86(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r12,%rbx,8),%rax
mov    (%rax),%edx
cmp    $0xffffffff,%edx
je     1160 <print_comm_schedule+0x40>
mov    $0x4,%r14d
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r12,%rbx,8),%rax
mov    (%rax,%r14,1),%edx
add    $0x4,%r14
cmp    $0xffffffff,%edx
jne    11a0 <print_comm_schedule+0x80>
jmp    1160 <print_comm_schedule+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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