void schreibe_int_array(const int array[], int laenge, int breite,
                        char *trenner, _Bool am_ende) {
  if (laenge != 0) {
    for (int i = 0; i < laenge - 1; i++)
      printf("%*d%s", breite, array[i], trenner);
    printf("%*d%s", breite, array[laenge - 1], am_ende ? trenner : "");
  }
}


x86 assembly (clang, -O0):
<schreibe_int_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %r8b,%al
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
and    $0x1,%al
mov    %al,-0x19(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11d6 <schreibe_int_array+0xc6>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    117e <schreibe_int_array+0x6e>
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x18(%rbp),%rcx
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    113f <schreibe_int_array+0x2f>
mov    -0x10(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x24(%rbp)
testb  $0x1,-0x19(%rbp)
je     11ae <schreibe_int_array+0x9e>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    11be <schreibe_int_array+0xae>
lea    0xe50(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    11be <schreibe_int_array+0xae>
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%esi
mov    -0x30(%rbp),%rcx
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<schreibe_int_array>:
test   %esi,%esi
je     11a5 <schreibe_int_array+0x95>
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%rbx
mov    %edx,%r15d
mov    %rdi,%rbp
mov    %r8d,0x4(%rsp)
lea    -0x1(%rsi),%eax
mov    %eax,(%rsp)
cmp    $0x2,%esi
jl     116e <schreibe_int_array+0x5e>
mov    (%rsp),%r14d
lea    0xeb9(%rip),%r12
xor    %r13d,%r13d
nopw   0x0(%rax,%rax,1)
mov    0x0(%rbp,%r13,4),%edx
mov    %r12,%rdi
mov    %r15d,%esi
mov    %rbx,%rcx
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%r13
cmp    %r13,%r14
jne    1150 <schreibe_int_array+0x40>
movslq (%rsp),%rax
mov    0x0(%rbp,%rax,4),%edx
lea    0xe88(%rip),%rcx
cmpb   $0x0,0x4(%rsp)
cmovne %rbx,%rcx
lea    0xe73(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>
ret

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

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