void schreibe_char_array(char *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_char_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     11d8 <schreibe_char_array+0xc8>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    117f <schreibe_char_array+0x6f>
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
mov    -0x18(%rbp),%rcx
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    113f <schreibe_char_array+0x2f>
mov    -0x10(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x24(%rbp)
testb  $0x1,-0x19(%rbp)
je     11b0 <schreibe_char_array+0xa0>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    11c0 <schreibe_char_array+0xb0>
lea    0xe4e(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    11c0 <schreibe_char_array+0xb0>
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%esi
mov    -0x30(%rbp),%rcx
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<schreibe_char_array>:
test   %esi,%esi
je     11a7 <schreibe_char_array+0x97>
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     116f <schreibe_char_array+0x5f>
mov    (%rsp),%r14d
lea    0xeb9(%rip),%r12
xor    %r13d,%r13d
nopw   0x0(%rax,%rax,1)
movsbl 0x0(%rbp,%r13,1),%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_char_array+0x40>
movslq (%rsp),%rax
movsbl 0x0(%rbp,%rax,1),%edx
lea    0xe86(%rip),%rcx
cmpb   $0x0,0x4(%rsp)
cmovne %rbx,%rcx
lea    0xe71(%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_char_array(i8* %0, i32 %1, i32 %2, i8* %3, i1 zeroext %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8
%11 = alloca i32
store i8* %0, i8** %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 %51
15: ; preds = %5
store i32 0, i32* %11
br label %16
16: ; preds = %31, %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 %34
21: ; preds = %16
%22 = load i32, i32* %8
%23 = load i8*, i8** %6
%24 = load i32, i32* %11
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = load i8*, i8** %9
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %22, i32 %28, i8* %29)
br label %31
31: ; preds = %21
%32 = load i32, i32* %11
%33 = add nsw i32 %32, 1
store i32 %33, i32* %11
br label %16
34: ; preds = %16
%35 = load i32, i32* %8
%36 = load i8*, i8** %6
%37 = load i32, i32* %7
%38 = sub nsw i32 %37, 1
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %36, i64 %39
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = load i8, i8* %10
%44 = trunc i8 %43 to i1
br i1 %44, label %45, label %47
45: ; preds = %34
%46 = load i8*, i8** %9
br label %48
47: ; preds = %34
br label %48
48: ; preds = %47, %45
%49 = phi i8* [ %46, %45 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), %47 ]
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %35, i32 %42, i8* %49)
br label %51
51: ; preds = %48, %5
ret void
}

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