#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*/ sprintf(int /*<<< orphan*/, char *, char);
void push(int *p, char *s[], char c) {
  if (*p < 5) {
    sprintf((*s)++, "%c", c);
    (*p)++;
  } else {
    sprintf((*s)++, "%c", '\0');
    return;
  }
}


x86 assembly (clang, -O0):
<push>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dl,%al
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    -0x8(%rbp),%rax
cmpl   $0x5,(%rax)
jge    1165 <push+0x55>
mov    -0x10(%rbp),%rcx
mov    (%rcx),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,(%rcx)
mov    %eax,%edi
lea    0xeb4(%rip),%rsi
movsbl -0x11(%rbp),%edx
call   1030 <sprintf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    1186 <push+0x76>
mov    -0x10(%rbp),%rcx
mov    (%rcx),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,(%rcx)
mov    %eax,%edi
lea    0xe81(%rip),%rsi
xor    %edx,%edx
call   1030 <sprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<push>:
push   %rbx
mov    %rdi,%rbx
mov    (%rsi),%rdi
lea    0x1(%rdi),%rax
cmpl   $0x4,(%rbx)
mov    %rax,(%rsi)
jg     1137 <push+0x27>
movsbl %dl,%edx
lea    0xed3(%rip),%rsi
call   1030 <sprintf@plt>
addl   $0x1,(%rbx)
pop    %rbx
ret
lea    0xec2(%rip),%rsi
xor    %edx,%edx
pop    %rbx
jmp    1030 <sprintf@plt>

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

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
define void @push(i32* nocapture %0, i8** nocapture %1, i8 signext %2) {
%4 = load i32, i32* %0
%5 = icmp slt i32 %4, 5
%6 = load i8*, i8** %1
%7 = getelementptr inbounds i8, i8* %6, i64 1
store i8* %7, i8** %1
%8 = ptrtoint i8* %6 to i64
%9 = trunc i64 %8 to i32
br i1 %5, label %10, label %14
10: ; preds = %3
%11 = tail call i32 @sprintf(i32 %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %2)
%12 = load i32, i32* %0
%13 = add nsw i32 %12, 1
store i32 %13, i32* %0
br label %16
14: ; preds = %3
%15 = tail call i32 @sprintf(i32 %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 0)
br label %16
16: ; preds = %14, %10
ret void
}