#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
char *malloc(scalar_t__);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int, char *, float);
int sscanf(char *, char *, char *, float *, int *);
int /*<<< orphan*/ stderr;
scalar_t__ strlen(char *);
void print_availability(char *availability) {
  char *type = malloc(strlen(availability) + 1);
  float price;
  int number;
  if (type == NULL) {
    perror("Unable to allocate necessary memory");
    exit(EXIT_FAILURE);
  }
  if (sscanf(availability, "%s %f %i", type, &price, &number) != 3) {
    fprintf(stderr, "Cannot read response\n");
    exit(EXIT_FAILURE);
  }
  printf("%3d room(s) of type %s at %.2f euros per night\n", number, type,
         price);
}


x86 assembly (clang, -O0):
<print_availability>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11ba <print_availability+0x4a>
lea    0xe59(%rip),%rdi
call   1080 <perror@plt>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe5b(%rip),%rsi
lea    -0x14(%rbp),%rcx
lea    -0x18(%rbp),%r8
call   1070 <sscanf@plt>
cmp    $0x3,%eax
je     1202 <print_availability+0x92>
mov    0x2dfa(%rip),%rax
mov    (%rax),%edi
lea    0xe3e(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2ddd(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    -0x18(%rbp),%esi
mov    -0x10(%rbp),%rdx
movss  -0x14(%rbp),%xmm0
lea    0xe2e(%rip),%rdi
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_availability>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <strlen@plt>
lea    0x1(%rax),%rdi
call   1060 <malloc@plt>
test   %rax,%rax
je     11cc <print_availability+0x5c>
mov    %rax,%rbx
lea    0xe90(%rip),%rsi
lea    0x4(%rsp),%rcx
mov    %rsp,%r8
mov    %r14,%rdi
mov    %rax,%rdx
call   1070 <sscanf@plt>
cmp    $0x3,%eax
jne    11da <print_availability+0x6a>
mov    (%rsp),%esi
movss  0x4(%rsp),%xmm0
lea    0xe87(%rip),%rdi
mov    %rbx,%rdx
call   1040 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe2d(%rip),%rdi
call   1080 <perror@plt>
jmp    11ef <print_availability+0x7f>
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
lea    0xe43(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [36 x i8] c"Unable to allocate necessary memory\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [9 x i8] c"%s %f %i\00"
@stderr = global i32 0
@.str.2 = [22 x i8] c"Cannot read response\0A\00"
@.str.3 = [48 x i8] c"%3d room(s) of type %s at %.2f euros per night\0A\00"
define void @print_availability(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca float
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i64 @strlen(i8* %6)
%8 = add nsw i64 %7, 1
%9 = call i8* @malloc(i64 %8)
store i8* %9, i8** %3
%10 = load i8*, i8** %3
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %16
12: ; preds = %1
%13 = call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%14 = load i32, i32* @EXIT_FAILURE
%15 = call i32 @exit(i32 %14)
unreachable
16: ; preds = %1
%17 = load i8*, i8** %2
%18 = load i8*, i8** %3
%19 = call i32 @sscanf(i8* %17, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %18, float* %4, i32* %5)
%20 = icmp ne i32 %19, 3
br i1 %20, label %21, label %26
21: ; preds = %16
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%24 = load i32, i32* @EXIT_FAILURE
%25 = call i32 @exit(i32 %24)
unreachable
26: ; preds = %16
%27 = load i32, i32* %5
%28 = load i8*, i8** %3
%29 = load float, float* %4
%30 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i32 %27, i8* %28, float %29)
ret void
}

LLVM IR (-O2):
@.str = [36 x i8] c"Unable to allocate necessary memory\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [9 x i8] c"%s %f %i\00"
@stderr = global i32 0
@.str.2 = [22 x i8] c"Cannot read response\0A\00"
@.str.3 = [48 x i8] c"%3d room(s) of type %s at %.2f euros per night\0A\00"
define void @print_availability(i8* nocapture %0) {
%2 = alloca float
%3 = alloca i32
%4 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%5 = add nsw i64 %4, 1
%6 = tail call i8* @malloc(i64 %5)
%7 = bitcast float* %2 to i8*
%8 = bitcast i32* %3 to i8*
%9 = icmp eq i8* %6, null
br i1 %9, label %10, label %14
10: ; preds = %1
%11 = tail call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
%13 = tail call i32 @exit(i32 %12)
unreachable
14: ; preds = %1
%15 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %6, float* %2, i32* %3)
%16 = icmp eq i32 %15, 3
br i1 %16, label %22, label %17
17: ; preds = %14
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%20 = load i32, i32* @EXIT_FAILURE
%21 = call i32 @exit(i32 %20)
unreachable
22: ; preds = %14
%23 = load i32, i32* %3
%24 = load float, float* %2
%25 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i32 %23, i8* %6, float %24)
ret void
}