#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 mod(int, int);
int /*<<< orphan*/ printf(char *, ...);
void printvec(int n, double *x, int modulo) {
  int i;
  if (modulo <= 0)
    modulo = 5;
  for (i = 1; i <= n; i++) {
    if (mod(i, modulo) == 1)
      printf("\n%2d:%12g", i, x[i]);
    else
      printf(" %2d:%12g", i, x[i]);
  }
  if (i % modulo != 0)
    printf("\n");
}


x86 assembly (clang, -O0):
<printvec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jg     1143 <printvec+0x23>
movl   $0x5,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11be <printvec+0x9e>
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1030 <mod@plt>
cmp    $0x1,%eax
jne    118d <printvec+0x6d>
mov    -0x18(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe7f(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    11ab <printvec+0x8b>
mov    -0x18(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe66(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    11b0 <printvec+0x90>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114a <printvec+0x2a>
mov    -0x18(%rbp),%eax
cltd
idivl  -0x14(%rbp)
cmp    $0x0,%edx
je     11dc <printvec+0xbc>
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printvec>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edx,%edx
mov    $0x5,%r15d
cmovg  %edx,%r15d
test   %edi,%edi
jle    119e <printvec+0x6e>
mov    %rsi,%r14
mov    %edi,%ebx
add    $0x1,%ebx
mov    $0x1,%ebp
lea    0xea1(%rip),%r12
lea    0xea4(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %r15d,%esi
call   1040 <mod@plt>
cmp    $0x1,%eax
movsd  (%r14,%rbp,8),%xmm0
mov    %r13,%rdi
cmove  %r12,%rdi
mov    %ebp,%esi
mov    $0x1,%al
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1170 <printvec+0x40>
jmp    11a3 <printvec+0x73>
mov    $0x1,%ebx
mov    %ebx,%eax
cltd
idiv   %r15d
test   %edx,%edx
je     11c5 <printvec+0x95>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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