#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 display_tupples(int *tupples, int num_ele, int cardinality) {
  printf("(");
  for (int i = 0; i < num_ele; i++) {
    if ((i % cardinality) == 0) {
      printf("  %d,", tupples[i]);
    } else {
      printf("%d,", tupples[i]);
    }
  }
  printf(")\n");
}


x86 assembly (clang, -O0):
<display_tupples>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    119d <display_tupples+0x8d>
mov    -0x14(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
jne    1171 <display_tupples+0x61>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    118a <display_tupples+0x7a>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    118f <display_tupples+0x7f>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1137 <display_tupples+0x27>
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_tupples>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%r15
mov    $0x28,%edi
call   1030 <putchar@plt>
test   %ebp,%ebp
jle    1196 <display_tupples+0x66>
mov    %ebp,%ebx
lea    0xea6(%rip),%r12
lea    0xea1(%rip),%r13
xor    %ebp,%ebp
jmp    1184 <display_tupples+0x54>
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r15,%rbp,4),%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
je     1196 <display_tupples+0x66>
mov    %ebp,%eax
cltd
idiv   %r14d
mov    %r12,%rdi
test   %edx,%edx
je     1170 <display_tupples+0x40>
mov    %r13,%rdi
jmp    1170 <display_tupples+0x40>
lea    0xe69(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

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

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