#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 *, ...);
void module1_section1_topic5() {
  double cast_to_float_double = 126.693254678905364578;
  float cast_to_int_float = (float)cast_to_float_double;
  int cast_to_char_int = (int)cast_to_int_float;
  char cast_bottom = (char)cast_to_char_int;
  printf("typecast pemdas down\n");
  printf("casts: %lf, %f, %d, %c\n", cast_to_float_double, cast_to_int_float,
         cast_to_char_int, cast_bottom);
  char *sentence = "you're a pathetic excuse for a human being";
  char char_from_string = *sentence;
  int int_from_char = (int)char_from_string;
  float float_from_int = (float)int_from_char;
  double double_from_float = (double)float_from_int;
  printf("typecast pemdas up\n");
  printf("casts: %s, %c, %d, %f, %lf\n", sentence, char_from_string,
         int_from_char, float_from_int, double_from_float);
}


x86 assembly (clang, -O0):
<module1_section1_topic5>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  0xee0(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
cvttss2si -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %al,-0x11(%rbp)
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mov    -0x10(%rbp),%esi
movsbl -0x11(%rbp),%edx
lea    0xeb3(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
lea    0xebd(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x21(%rbp)
movsbl -0x21(%rbp),%eax
mov    %eax,-0x28(%rbp)
cvtsi2ssl -0x28(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x2c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rsi
movsbl -0x21(%rbp),%edx
mov    -0x28(%rbp),%ecx
movss  -0x2c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  -0x38(%rbp),%xmm1
lea    0xea2(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<module1_section1_topic5>:
push   %rax
lea    0xf4f(%rip),%rdi
call   1030 <puts@plt>
lea    0xee4(%rip),%rdi
movsd  0xec4(%rip),%xmm0
movsd  0xec4(%rip),%xmm1
mov    $0x7e,%esi
mov    $0x7e,%edx
mov    $0x2,%al
call   1040 <printf@plt>
lea    0xf30(%rip),%rdi
call   1030 <puts@plt>
lea    0xef3(%rip),%rdi
lea    0xec1(%rip),%rsi
movsd  0xe99(%rip),%xmm0
mov    $0x79,%edx
mov    $0x79,%ecx
movaps %xmm0,%xmm1
mov    $0x2,%al
pop    %r8
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"typecast pemdas down\0A\00"
@.str.1 = [24 x i8] c"casts: %lf, %f, %d, %c\0A\00"
@.str.2 = [43 x i8] c"you're a pathetic excuse for a human being\00"
@.str.3 = [20 x i8] c"typecast pemdas up\0A\00"
@.str.4 = [28 x i8] c"casts: %s, %c, %d, %f, %lf\0A\00"
define void @module1_section1_topic5() {
%1 = alloca double
%2 = alloca float
%3 = alloca i32
%4 = alloca i8
%5 = alloca i8*
%6 = alloca i8
%7 = alloca i32
%8 = alloca float
%9 = alloca double
store double 0x405FAC5E48DF6CA4, double* %1
%10 = load double, double* %1
%11 = fptrunc double %10 to float
store float %11, float* %2
%12 = load float, float* %2
%13 = fptosi float %12 to i32
store i32 %13, i32* %3
%14 = load i32, i32* %3
%15 = trunc i32 %14 to i8
store i8 %15, i8* %4
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%17 = load double, double* %1
%18 = load float, float* %2
%19 = fpext float %18 to double
%20 = load i32, i32* %3
%21 = load i8, i8* %4
%22 = sext i8 %21 to i32
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), double %17, double %19, i32 %20, i32 %22)
store i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i8** %5
%24 = load i8*, i8** %5
%25 = load i8, i8* %24
store i8 %25, i8* %6
%26 = load i8, i8* %6
%27 = sext i8 %26 to i32
store i32 %27, i32* %7
%28 = load i32, i32* %7
%29 = sitofp i32 %28 to float
store float %29, float* %8
%30 = load float, float* %8
%31 = fpext float %30 to double
store double %31, double* %9
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%33 = load i8*, i8** %5
%34 = load i8, i8* %6
%35 = sext i8 %34 to i32
%36 = load i32, i32* %7
%37 = load float, float* %8
%38 = fpext float %37 to double
%39 = load double, double* %9
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i8* %33, i32 %35, i32 %36, double %38, double %39)
ret void
}

LLVM IR (-O2):
@.str.1 = [24 x i8] c"casts: %lf, %f, %d, %c\0A\00"
@.str.2 = [43 x i8] c"you're a pathetic excuse for a human being\00"
@.str.4 = [28 x i8] c"casts: %s, %c, %d, %f, %lf\0A\00"
@str = [21 x i8] c"typecast pemdas down\00"
@str.5 = [19 x i8] c"typecast pemdas up\00"
define void @module1_section1_topic5() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), double 0x405FAC5E48DF6CA4, double 0x405FAC5E40000000, i32 126, i32 126)
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.5, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i32 121, i32 121, double 1.210000e+02, double 1.210000e+02)
ret void
}