#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 *, int);
int /*<<< orphan*/ putchar(char);
void print_te_part(char *arr, int len, int offs) {
  int first = 1, i;
  for (i = 0; i < len; i++) {
    if (arr[i]) {
      if (!first)
        putchar(',');
      printf("%d", i + offs);
      first = 0;
    }
  }
}


x86 assembly (clang, -O0):
<print_te_part>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    119e <print_te_part+0x7e>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     118b <print_te_part+0x6b>
cmpl   $0x0,-0x14(%rbp)
jne    1172 <print_te_part+0x52>
mov    $0x2c,%edi
call   1030 <putchar@plt>
mov    -0x18(%rbp),%esi
add    -0x10(%rbp),%esi
lea    0xe81(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
jmp    1190 <print_te_part+0x70>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1140 <print_te_part+0x20>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_te_part>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %esi,%esi
jle    117e <print_te_part+0x5e>
mov    %rdi,%r15
mov    %esi,%r13d
mov    %edx,%r12d
mov    $0x1,%eax
xor    %ebx,%ebx
lea    0xebc(%rip),%r14
jmp    1167 <print_te_part+0x47>
cs nopw 0x0(%rax,%rax,1)
lea    (%r12,%rbx,1),%esi
mov    %r14,%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x1,%rbx
cmp    %rbx,%r13
je     117e <print_te_part+0x5e>
cmpb   $0x0,(%r15,%rbx,1)
je     115e <print_te_part+0x3e>
test   %eax,%eax
jne    1150 <print_te_part+0x30>
mov    $0x2c,%edi
call   1030 <putchar@plt>
jmp    1150 <print_te_part+0x30>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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