#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 printTable(int sales[][6]) {
  printf("\n=== Sales Information table for the last %d days ===\n\n", 2);
  printf("SP No\tProd 1\tProd 2\tProd 3\tProd 4\tProd 5\t TOTAL\n");
  int salesperson, product;
  int prodTotals[6] = {0};
  int salesPersonTotal = 0;
  int allSales = 0;
  for (salesperson = 1; salesperson < 5; salesperson++) {
    salesPersonTotal = 0;
    for (product = 1; product < 6; product++) {
      prodTotals[product] += sales[salesperson][product];
      salesPersonTotal += sales[salesperson][product];
    }
    allSales += salesPersonTotal;
    printf("%5d", salesperson);
    for (product = 1; product < 6; product++) {
      printf("\t%6d", sales[salesperson][product]);
    }
    printf("\t%6d\n", salesPersonTotal);
  }
  printf("\nTOTAL");
  for (product = 1; product < 6; product++) {
    printf("\t%6d", prodTotals[product]);
  }
  printf("\t%6d\n", allSales);
}


x86 assembly (clang, -O0):
<printTable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xecd(%rip),%rdi
mov    $0x2,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1040 <memset@plt>
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x1,-0xc(%rbp)
cmpl   $0x5,-0xc(%rbp)
jge    125c <printTable+0x13c>
movl   $0x0,-0x34(%rbp)
movl   $0x1,-0x10(%rbp)
cmpl   $0x6,-0x10(%rbp)
jge    11e0 <printTable+0xc0>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
movslq -0x10(%rbp),%rax
add    -0x30(%rbp,%rax,4),%ecx
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
add    -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    118a <printTable+0x6a>
mov    -0x34(%rbp),%eax
add    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x10(%rbp)
cmpl   $0x6,-0x10(%rbp)
jge    123d <printTable+0x11d>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1201 <printTable+0xe1>
mov    -0x34(%rbp),%esi
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1172 <printTable+0x52>
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x10(%rbp)
cmpl   $0x6,-0x10(%rbp)
jge    129f <printTable+0x17f>
movslq -0x10(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1271 <printTable+0x151>
mov    -0x38(%rbp),%esi
lea    0xdc9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printTable>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbp
lea    0xec8(%rip),%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf03(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%r15d
xor    %r13d,%r13d
xor    %r14d,%r14d
xor    %ebx,%ebx
movl   $0x0,0x4(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x0,0xc(%rsp)
movl   $0x0,0x10(%rsp)
xchg   %ax,%ax
mov    0x1c(%rbp,%r13,1),%eax
mov    0x20(%rbp,%r13,1),%r12d
add    %eax,%r14d
add    %r12d,%ebx
mov    %ebx,0x14(%rsp)
add    %eax,%r12d
mov    0x24(%rbp,%r13,1),%eax
add    %eax,0x4(%rsp)
add    %eax,%r12d
mov    0x28(%rbp,%r13,1),%eax
add    %eax,0x8(%rsp)
add    %eax,%r12d
mov    0x2c(%rbp,%r13,1),%eax
add    %eax,0xc(%rsp)
add    %eax,%r12d
lea    0xe76(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x1c(%rbp,%r13,1),%esi
lea    0xe64(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x20(%rbp,%r13,1),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x24(%rbp,%r13,1),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x28(%rbp,%r13,1),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2c(%rbp,%r13,1),%esi
mov    %rbx,%rdi
mov    0x14(%rsp),%ebx
xor    %eax,%eax
call   1040 <printf@plt>
add    %r12d,0x10(%rsp)
lea    0xe13(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r15d
add    $0x18,%r13
cmp    $0x60,%r13
jne    1180 <printTable+0x60>
lea    0xdf6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xddd(%rip),%rbp
mov    %rbp,%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    0x4(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    0x8(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    0xc(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd98(%rip),%rdi
mov    0x10(%rsp),%esi
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [56 x i8] c"\0A=== Sales Information table for the last %d days ===\0A\0A\00"
@.str.1 = [49 x i8] c"SP No\09Prod 1\09Prod 2\09Prod 3\09Prod 4\09Prod 5\09 TOTAL\0A\00"
@.str.2 = [4 x i8] c"%5d\00"
@.str.3 = [5 x i8] c"\09%6d\00"
@.str.4 = [6 x i8] c"\09%6d\0A\00"
@.str.5 = [7 x i8] c"\0ATOTAL\00"
define void @printTable([6 x i32]* %0) {
%2 = alloca [6 x i32]*
%3 = alloca i32
%4 = alloca i32
%5 = alloca [6 x i32]
%6 = alloca i32
%7 = alloca i32
store [6 x i32]* %0, [6 x i32]** %2
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i32 2)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
%10 = bitcast [6 x i32]* %5 to i8*
store i32 0, i32* %6
store i32 0, i32* %7
store i32 1, i32* %3
br label %11
11: ; preds = %70, %1
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 5
br i1 %13, label %14, label %73
14: ; preds = %11
store i32 0, i32* %6
store i32 1, i32* %4
br label %15
15: ; preds = %42, %14
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 6
br i1 %17, label %18, label %45
18: ; preds = %15
%19 = load [6 x i32]*, [6 x i32]** %2
%20 = load i32, i32* %3
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [6 x i32], [6 x i32]* %19, i64 %21
%23 = load i32, i32* %4
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [6 x i32], [6 x i32]* %22, i64 0, i64 %24
%26 = load i32, i32* %25
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [6 x i32], [6 x i32]* %5, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = add nsw i32 %30, %26
store i32 %31, i32* %29
%32 = load [6 x i32]*, [6 x i32]** %2
%33 = load i32, i32* %3
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [6 x i32], [6 x i32]* %32, i64 %34
%36 = load i32, i32* %4
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [6 x i32], [6 x i32]* %35, i64 0, i64 %37
%39 = load i32, i32* %38
%40 = load i32, i32* %6
%41 = add nsw i32 %40, %39
store i32 %41, i32* %6
br label %42
42: ; preds = %18
%43 = load i32, i32* %4
%44 = add nsw i32 %43, 1
store i32 %44, i32* %4
br label %15
45: ; preds = %15
%46 = load i32, i32* %6
%47 = load i32, i32* %7
%48 = add nsw i32 %47, %46
store i32 %48, i32* %7
%49 = load i32, i32* %3
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %49)
store i32 1, i32* %4
br label %51
51: ; preds = %64, %45
%52 = load i32, i32* %4
%53 = icmp slt i32 %52, 6
br i1 %53, label %54, label %67
54: ; preds = %51
%55 = load [6 x i32]*, [6 x i32]** %2
%56 = load i32, i32* %3
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [6 x i32], [6 x i32]* %55, i64 %57
%59 = load i32, i32* %4
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [6 x i32], [6 x i32]* %58, i64 0, i64 %60
%62 = load i32, i32* %61
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %62)
br label %64
64: ; preds = %54
%65 = load i32, i32* %4
%66 = add nsw i32 %65, 1
store i32 %66, i32* %4
br label %51
67: ; preds = %51
%68 = load i32, i32* %6
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %68)
br label %70
70: ; preds = %67
%71 = load i32, i32* %3
%72 = add nsw i32 %71, 1
store i32 %72, i32* %3
br label %11
73: ; preds = %11
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %4
br label %75
75: ; preds = %84, %73
%76 = load i32, i32* %4
%77 = icmp slt i32 %76, 6
br i1 %77, label %78, label %87
78: ; preds = %75
%79 = load i32, i32* %4
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds [6 x i32], [6 x i32]* %5, i64 0, i64 %80
%82 = load i32, i32* %81
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %82)
br label %84
84: ; preds = %78
%85 = load i32, i32* %4
%86 = add nsw i32 %85, 1
store i32 %86, i32* %4
br label %75
87: ; preds = %75
%88 = load i32, i32* %7
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %88)
ret void
}

LLVM IR (-O2):
@.str = [56 x i8] c"\0A=== Sales Information table for the last %d days ===\0A\0A\00"
@.str.2 = [4 x i8] c"%5d\00"
@.str.3 = [5 x i8] c"\09%6d\00"
@.str.4 = [6 x i8] c"\09%6d\0A\00"
@.str.5 = [7 x i8] c"\0ATOTAL\00"
@str = [48 x i8] c"SP No\09Prod 1\09Prod 2\09Prod 3\09Prod 4\09Prod 5\09 TOTAL\00"
define void @printTable([6 x i32]* nocapture %0) {
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i32 2)
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str, i64 0, i64 0))
br label %4
4: ; preds = %1, %4
%5 = phi i32 [ 0, %1 ], [ %14, %4 ]
%6 = phi i32 [ 0, %1 ], [ %17, %4 ]
%7 = phi i32 [ 0, %1 ], [ %21, %4 ]
%8 = phi i32 [ 0, %1 ], [ %25, %4 ]
%9 = phi i32 [ 0, %1 ], [ %29, %4 ]
%10 = phi i64 [ 1, %1 ], [ %45, %4 ]
%11 = phi i32 [ 0, %1 ], [ %43, %4 ]
%12 = getelementptr inbounds [6 x i32], [6 x i32]* %0, i64 %10, i64 1
%13 = load i32, i32* %12
%14 = add nsw i32 %5, %13
%15 = getelementptr inbounds [6 x i32], [6 x i32]* %0, i64 %10, i64 2
%16 = load i32, i32* %15
%17 = add nsw i32 %6, %16
%18 = add nsw i32 %16, %13
%19 = getelementptr inbounds [6 x i32], [6 x i32]* %0, i64 %10, i64 3
%20 = load i32, i32* %19
%21 = add nsw i32 %7, %20
%22 = add nsw i32 %20, %18
%23 = getelementptr inbounds [6 x i32], [6 x i32]* %0, i64 %10, i64 4
%24 = load i32, i32* %23
%25 = add nsw i32 %8, %24
%26 = add nsw i32 %24, %22
%27 = getelementptr inbounds [6 x i32], [6 x i32]* %0, i64 %10, i64 5
%28 = load i32, i32* %27
%29 = add nsw i32 %9, %28
%30 = add nsw i32 %28, %26
%31 = trunc i64 %10 to i32
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %12
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %33)
%35 = load i32, i32* %15
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %35)
%37 = load i32, i32* %19
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %37)
%39 = load i32, i32* %23
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %39)
%41 = load i32, i32* %27
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %41)
%43 = add nsw i32 %30, %11
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %30)
%45 = add nuw nsw i64 %10, 1
%46 = icmp eq i64 %45, 5
br i1 %46, label %47, label %4
47: ; preds = %4
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%49 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %14)
%50 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%51 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %21)
%52 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %25)
%53 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %29)
%54 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %43)
ret void
}