#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 const *, ...);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
int /*<<< orphan*/ trim(char *, char *);
void print_array(char *s, char *cnstr, void *a, int sz) {
  printf("%s", s);
  char cs[32];
  trim(cs, cnstr);
  strcat(cs, " ");
  int i;
  for (i = 0; i < sz; i++) {
    if (strlen(cs) > 1 && (cs[0] == '%' && (cs[strlen(cs) - 2] == 'd'))) {
      printf((const char *)(cs), *((int *)a + i));
    } else if (strlen(cs) > 1 &&
               (cs[0] == '%' && (cs[strlen(cs) - 2] == 'f'))) {
      printf((const char *)(cs), *((float *)a + i));
    }
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<print_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <trim@plt>
lea    -0x40(%rbp),%rdi
lea    0xe82(%rip),%rsi
call   1060 <strcat@plt>
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    125e <print_array+0x11e>
lea    -0x40(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x1,%eax
jle    11ef <print_array+0xaf>
movsbl -0x40(%rbp),%eax
cmp    $0x25,%eax
jne    11ef <print_array+0xaf>
lea    -0x40(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x2,%eax
cltq
movsbl -0x40(%rbp,%rax,1),%eax
cmp    $0x64,%eax
jne    11ef <print_array+0xaf>
lea    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    124b <print_array+0x10b>
lea    -0x40(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x1,%eax
jle    1246 <print_array+0x106>
movsbl -0x40(%rbp),%eax
cmp    $0x25,%eax
jne    1246 <print_array+0x106>
lea    -0x40(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x2,%eax
cltq
movsbl -0x40(%rbp,%rax,1),%eax
cmp    $0x66,%eax
jne    1246 <print_array+0x106>
lea    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x44(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
jmp    124b <print_array+0x10b>
jmp    1250 <print_array+0x110>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    118d <print_array+0x4d>
lea    0xda0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_array>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %ecx,%r15d
mov    %rdx,%r14
mov    %rsi,%rbp
mov    %rdi,%rsi
lea    0xe93(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1060 <trim@plt>
lea    0xe7a(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
test   %r15d,%r15d
jle    1215 <print_array+0xc5>
mov    %r15d,%r15d
xor    %ebp,%ebp
jmp    11b7 <print_array+0x67>
nopl   (%rax)
mov    (%r14,%rbp,4),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
je     1215 <print_array+0xc5>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jl     11db <print_array+0x8b>
cmpb   $0x25,(%rsp)
jne    11db <print_array+0x8b>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0x64,-0x2(%rax,%rbx,1)
je     11a0 <print_array+0x50>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jl     11ae <print_array+0x5e>
cmpb   $0x25,(%rsp)
jne    11ae <print_array+0x5e>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0x66,-0x2(%rax,%rbx,1)
jne    11ae <print_array+0x5e>
movss  (%r14,%rbp,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
jmp    11ae <print_array+0x5e>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [2 x i8] c"\0A\00"
define void @print_array(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca [32 x i8]
%10 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%11 = load i8*, i8** %5
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%14 = load i8*, i8** %6
%15 = call i32 @trim(i8* %13, i8* %14)
%16 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%17 = call i32 @strcat(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %10
br label %18
18: ; preds = %79, %4
%19 = load i32, i32* %10
%20 = load i32, i32* %8
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %82
22: ; preds = %18
%23 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%24 = call i32 @strlen(i8* %23)
%25 = icmp sgt i32 %24, 1
br i1 %25, label %26, label %49
26: ; preds = %22
%27 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 37
br i1 %30, label %31, label %49
31: ; preds = %26
%32 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%33 = call i32 @strlen(i8* %32)
%34 = sub nsw i32 %33, 2
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 100
br i1 %39, label %40, label %49
40: ; preds = %31
%41 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%42 = load i8*, i8** %7
%43 = bitcast i8* %42 to i32*
%44 = load i32, i32* %10
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i32, i32* %43, i64 %45
%47 = load i32, i32* %46
%48 = call i32 (i8*, ...) @printf(i8* %41, i32 %47)
br label %78
49: ; preds = %31, %26, %22
%50 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%51 = call i32 @strlen(i8* %50)
%52 = icmp sgt i32 %51, 1
br i1 %52, label %53, label %77
53: ; preds = %49
%54 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = icmp eq i32 %56, 37
br i1 %57, label %58, label %77
58: ; preds = %53
%59 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%60 = call i32 @strlen(i8* %59)
%61 = sub nsw i32 %60, 2
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 %62
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
%66 = icmp eq i32 %65, 102
br i1 %66, label %67, label %77
67: ; preds = %58
%68 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%69 = load i8*, i8** %7
%70 = bitcast i8* %69 to float*
%71 = load i32, i32* %10
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds float, float* %70, i64 %72
%74 = load float, float* %73
%75 = fpext float %74 to double
%76 = call i32 (i8*, ...) @printf(i8* %68, double %75)
br label %77
77: ; preds = %67, %58, %53, %49
br label %78
78: ; preds = %77, %40
br label %79
79: ; preds = %78
%80 = load i32, i32* %10
%81 = add nsw i32 %80, 1
store i32 %81, i32* %10
br label %18
82: ; preds = %18
%83 = 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 = [3 x i8] c"%s\00"
@.str.1 = [2 x i8] c" \00"
define void @print_array(i8* %0, i8* %1, i8* nocapture %2, i32 %3) {
%5 = alloca [32 x i8]
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
%7 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%8 = call i32 @trim(i8* %7, i8* %1)
%9 = call i32 @strcat(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp sgt i32 %3, 0
br i1 %10, label %11, label %54
11: ; preds = %4
%12 = bitcast i8* %2 to float*
%13 = bitcast i8* %2 to i32*
%14 = zext i32 %3 to i64
br label %15
15: ; preds = %11, %51
%16 = phi i64 [ 0, %11 ], [ %52, %51 ]
%17 = call i32 @strlen(i8* %7)
%18 = icmp sgt i32 %17, 1
%19 = load i8, i8* %7
%20 = icmp eq i8 %19, 37
%21 = select i1 %18, i1 %20, i1 false
br i1 %21, label %22, label %33
22: ; preds = %15
%23 = call i32 @strlen(i8* %7)
%24 = add nsw i32 %23, -2
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 100
br i1 %28, label %29, label %33
29: ; preds = %22
%30 = getelementptr inbounds i32, i32* %13, i64 %16
%31 = load i32, i32* %30
%32 = call i32 (i8*, ...) @printf(i8* %7, i32 %31)
br label %51
33: ; preds = %22, %15
%34 = call i32 @strlen(i8* %7)
%35 = icmp sgt i32 %34, 1
%36 = load i8, i8* %7
%37 = icmp eq i8 %36, 37
%38 = select i1 %35, i1 %37, i1 false
br i1 %38, label %39, label %51
39: ; preds = %33
%40 = call i32 @strlen(i8* %7)
%41 = add nsw i32 %40, -2
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 %42
%44 = load i8, i8* %43
%45 = icmp eq i8 %44, 102
br i1 %45, label %46, label %51
46: ; preds = %39
%47 = getelementptr inbounds float, float* %12, i64 %16
%48 = load float, float* %47
%49 = fpext float %48 to double
%50 = call i32 (i8*, ...) @printf(i8* %7, double %49)
br label %51
51: ; preds = %29, %46, %39, %33
%52 = add nuw nsw i64 %16, 1
%53 = icmp eq i64 %52, %14
br i1 %53, label %54, label %15
54: ; preds = %51, %4
%55 = call i32 @putchar(i32 10)
ret void
}