#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*/ free(char *);
char *malloc(size_t const);
int /*<<< orphan*/ printf(char *, char *);
int snprintf(char *, size_t const, char *, char *, int, char *, int);
int main() {
  char wochentag[] = "Freitag";
  int tag = 13;
  char monat[] = "Mai";
  int jahr = 1927;
  char *string;
  const size_t kapazitaet =
      snprintf(NULL, 0, "%s, der %i. %s %i", wochentag, tag, monat, jahr) + 1;
  string = malloc(kapazitaet);
  snprintf(string, kapazitaet, "%s, der %i. %s %i", wochentag, tag, monat,
           jahr);
  printf("%s\n", string);
  free(string);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0xc(%rbp)
movl   $0xd,-0x10(%rbp)
mov    0xea1(%rip),%eax
mov    %eax,-0x14(%rbp)
movl   $0x787,-0x18(%rbp)
lea    -0xc(%rbp),%rcx
mov    -0x10(%rbp),%r8d
lea    -0x14(%rbp),%r9
mov    -0x18(%rbp),%eax
xor    %edx,%edx
mov    %edx,%esi
lea    0xe81(%rip),%rdx
mov    %rsi,%rdi
mov    %eax,(%rsp)
call   1050 <snprintf@plt>
add    $0x1,%eax
cltq
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
lea    -0xc(%rbp),%rcx
mov    -0x10(%rbp),%r8d
lea    -0x14(%rbp),%r9
mov    -0x18(%rbp),%eax
lea    0xe42(%rip),%rdx
mov    %eax,(%rsp)
call   1050 <snprintf@plt>
mov    -0x20(%rbp),%rsi
lea    0xe41(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
movabs $0x67617469657246,%rax
mov    %rax,0x18(%rsp)
movl   $0x69614d,0x14(%rsp)
movl   $0x787,(%rsp)
lea    0xe8e(%rip),%r14
lea    0x18(%rsp),%r12
lea    0x14(%rsp),%r15
xor    %edi,%edi
xor    %esi,%esi
mov    %r14,%rdx
mov    %r12,%rcx
mov    $0xd,%r8d
mov    %r15,%r9
call   1050 <snprintf@plt>
add    $0x1,%eax
movslq %eax,%r13
mov    %r13,%rdi
call   1060 <malloc@plt>
mov    %rax,%rbx
movl   $0x787,(%rsp)
mov    %rax,%rdi
mov    %r13,%rsi
mov    %r14,%rdx
mov    %r12,%rcx
mov    $0xd,%r8d
mov    %r15,%r9
call   1050 <snprintf@plt>
lea    0xe45(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.wochentag = [8 x i8] c"Freitag\00"
@__const.main.monat = [4 x i8] c"Mai\00"
@.str = [18 x i8] c"%s, der %i. %s %i\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [8 x i8]
%3 = alloca i32
%4 = alloca [4 x i8]
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
store i32 0, i32* %1
%8 = bitcast [8 x i8]* %2 to i8*
store i32 13, i32* %3
%9 = bitcast [4 x i8]* %4 to i8*
store i32 1927, i32* %5
%10 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%11 = load i32, i32* %3
%12 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%13 = load i32, i32* %5
%14 = call i32 @snprintf(i8* null, i64 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %10, i32 %11, i8* %12, i32 %13)
%15 = add nsw i32 %14, 1
%16 = sext i32 %15 to i64
store i64 %16, i64* %7
%17 = load i64, i64* %7
%18 = call i8* @malloc(i64 %17)
store i8* %18, i8** %6
%19 = load i8*, i8** %6
%20 = load i64, i64* %7
%21 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%22 = load i32, i32* %3
%23 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%24 = load i32, i32* %5
%25 = call i32 @snprintf(i8* %19, i64 %20, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %21, i32 %22, i8* %23, i32 %24)
%26 = load i8*, i8** %6
%27 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %26)
%28 = load i8*, i8** %6
%29 = call i32 @free(i8* %28)
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"%s, der %i. %s %i\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i32
%3 = bitcast i64* %1 to i8*
store i64 29099075213554246, i64* %1
%4 = bitcast i32* %2 to i8*
store i32 6906189, i32* %2
%5 = call i32 @snprintf(i8* null, i64 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %3, i32 13, i8* %4, i32 1927)
%6 = add nsw i32 %5, 1
%7 = sext i32 %6 to i64
%8 = call i8* @malloc(i64 %7)
%9 = call i32 @snprintf(i8* %8, i64 %7, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %3, i32 13, i8* %4, i32 1927)
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%11 = call i32 @free(i8* %8)
ret i32 0
}