#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 imprimir_particao(int *p, int tamanho) {
  printf("{");
  for (int i = 0; i < tamanho; i++) {
    if (p[i] != 0) {
      printf("%d", p[i]);
      if (i < tamanho - 1 && p[i + 1] != 0) {
        printf(",");
      }
    }
  }
  printf("};\r\n");
}


x86 assembly (clang, -O0):
<imprimir_particao>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b9 <imprimir_particao+0xa9>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     11a6 <imprimir_particao+0x96>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11a1 <imprimir_particao+0x91>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     11a1 <imprimir_particao+0x91>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a6 <imprimir_particao+0x96>
jmp    11ab <imprimir_particao+0x9b>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1134 <imprimir_particao+0x24>
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<imprimir_particao>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %esi,%r14d
mov    %rdi,%r13
mov    $0x7b,%edi
call   1030 <putchar@plt>
test   %r14d,%r14d
jle    1195 <imprimir_particao+0x65>
lea    -0x1(%r14),%r15d
mov    %r14d,%r12d
lea    0xea4(%rip),%r14
xor    %ebx,%ebx
jmp    1169 <imprimir_particao+0x39>
add    $0x1,%rbx
cmp    %rbx,%r12
je     1195 <imprimir_particao+0x65>
mov    0x0(%r13,%rbx,4),%esi
test   %esi,%esi
je     1160 <imprimir_particao+0x30>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    %r15,%rbx
jae    1160 <imprimir_particao+0x30>
cmpl   $0x0,0x4(%r13,%rbx,4)
je     1160 <imprimir_particao+0x30>
mov    $0x2c,%edi
call   1030 <putchar@plt>
jmp    1160 <imprimir_particao+0x30>
lea    0xe67(%rip),%rdi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1040 <puts@plt>

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

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