#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 */
scalar_t__ piece(char *, char, char *, int);
int /*<<< orphan*/ printf(char *, ...);
void local_single_quotes_around(char *string) {
  char buffer[1024];
  int i;
  for (i = 0; piece(buffer, ',', string, i); i++) {
    if (i == 0)
      printf("'%s'", buffer);
    else
      printf(",'%s'", buffer);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<local_single_quotes_around>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x414(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x414(%rbp),%ecx
mov    $0x2c,%esi
call   1040 <piece@plt>
cmp    $0x0,%rax
je     11b3 <local_single_quotes_around+0x93>
cmpl   $0x0,-0x414(%rbp)
jne    1185 <local_single_quotes_around+0x65>
lea    -0x410(%rbp),%rsi
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    119a <local_single_quotes_around+0x7a>
lea    -0x410(%rbp),%rsi
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    119f <local_single_quotes_around+0x7f>
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
jmp    1139 <local_single_quotes_around+0x19>
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<local_single_quotes_around>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %rdi,%r15
mov    %rsp,%rdi
mov    $0x2c,%esi
mov    %r15,%rdx
xor    %ecx,%ecx
call   1050 <piece@plt>
test   %rax,%rax
je     11c7 <local_single_quotes_around+0x97>
lea    0xea3(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x2c,%esi
mov    %r15,%rdx
mov    $0x1,%ecx
call   1050 <piece@plt>
test   %rax,%rax
je     11c7 <local_single_quotes_around+0x97>
mov    $0x2,%ebp
lea    0xe6f(%rip),%r14
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x2c,%esi
mov    %r15,%rdx
mov    %ebp,%ecx
call   1050 <piece@plt>
add    $0x1,%ebp
test   %rax,%rax
jne    11a0 <local_single_quotes_around+0x70>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"'%s'\00"
@.str.1 = [6 x i8] c",'%s'\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @local_single_quotes_around(i8* %0) {
%2 = alloca i8*
%3 = alloca [1024 x i8]
%4 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %4
br label %5
5: ; preds = %21, %1
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%7 = load i8*, i8** %2
%8 = load i32, i32* %4
%9 = call i64 @piece(i8* %6, i8 signext 44, i8* %7, i32 %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %24
11: ; preds = %5
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %15)
br label %20
17: ; preds = %11
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %17, %14
br label %21
21: ; preds = %20
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
br label %5
24: ; preds = %5
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"'%s'\00"
@.str.1 = [6 x i8] c",'%s'\00"
define void @local_single_quotes_around(i8* %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = call i64 @piece(i8* %3, i8 signext 44, i8* %0, i32 0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %16, label %6
6: ; preds = %1
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %3)
%8 = call i64 @piece(i8* %3, i8 signext 44, i8* %0, i32 1)
%9 = icmp eq i64 %8, 0
br i1 %9, label %16, label %10
10: ; preds = %6, %10
%11 = phi i32 [ %13, %10 ], [ 1, %6 ]
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%13 = add nuw nsw i32 %11, 1
%14 = call i64 @piece(i8* %3, i8 signext 44, i8* %0, i32 %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %10
16: ; preds = %10, %6, %1
%17 = call i32 @putchar(i32 10)
ret void
}