#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 */
double M_PI;
double atof(char *);
double cos(double);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
double sin(double);
int main(int argc, char *argv[]) {
  double width, height, angle, radian;
  double w, h, w1, w2;
  if (argc != 4) {
    printf("Usage:/%s <width> <height> <angle> of the original image, and the "
           "angle want to rotate, then I'll reply with the reduced size of "
           "image width and height.\n",
           argv[0]);
    exit(1);
  }
  width = atof(argv[1]);
  height = atof(argv[2]);
  angle = atof(argv[3]);
  radian = angle * M_PI / 180;
  w1 = width / ((height / width) * sin(radian) + cos(radian));
  w2 = height / (sin(radian) + (height / width) * cos(radian));
  w = w1 < w2 ? w1 : w2;
  h = w * height / width;
  printf(
      "Rotated: w %.0f h %.0f \nOriginal: width %.0f height %.0f radian %f.\n",
      w, h, width, height, radian);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     1192 <main+0x42>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    0x2e14(%rip),%rax
mulsd  (%rax),%xmm0
movsd  0xe20(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x20(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,-0x78(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1060 <cos@plt>
movsd  -0x80(%rbp),%xmm1
movsd  -0x78(%rbp),%xmm3
movaps %xmm0,%xmm2
movsd  -0x70(%rbp),%xmm0
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x20(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1060 <cos@plt>
movsd  -0x68(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12b9 <main+0x169>
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
jmp    12c6 <main+0x176>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x88(%rbp),%xmm0
ff
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm3
movsd  -0x30(%rbp),%xmm4
lea    0xd9b(%rip),%rdi
mov    $0x5,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x70,%rsp
mov    %rsi,%rbx
cmp    $0x4,%edi
jne    1261 <main+0x111>
mov    0x8(%rbx),%rdi
call   1030 <atof@plt>
movapd %xmm0,0x20(%rsp)
mov    0x10(%rbx),%rdi
call   1030 <atof@plt>
movapd %xmm0,0x10(%rsp)
mov    0x18(%rbx),%rdi
call   1030 <atof@plt>
mov    0x2e59(%rip),%rax
mulsd  (%rax),%xmm0
divsd  0xe65(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
movapd 0x10(%rsp),%xmm1
divsd  0x20(%rsp),%xmm1
movapd %xmm1,0x60(%rsp)
call   1050 <sin@plt>
movapd %xmm0,0x50(%rsp)
movsd  0x8(%rsp),%xmm0
call   1060 <cos@plt>
movaps %xmm0,0x40(%rsp)
movsd  0x8(%rsp),%xmm0
call   1050 <sin@plt>
movaps %xmm0,0x30(%rsp)
movsd  0x8(%rsp),%xmm0
call   1060 <cos@plt>
movapd 0x60(%rsp),%xmm1
unpcklpd %xmm1,%xmm1
movapd 0x50(%rsp),%xmm2
unpcklpd %xmm0,%xmm2
mulpd  %xmm1,%xmm2
movapd 0x40(%rsp),%xmm0
unpcklpd 0x30(%rsp),%xmm0
addpd  %xmm2,%xmm0
movapd %xmm0,%xmm1
movapd 0x20(%rsp),%xmm2
movapd %xmm2,%xmm0
movapd 0x10(%rsp),%xmm3
unpcklpd %xmm3,%xmm0
divpd  %xmm1,%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
minsd  %xmm1,%xmm0
movapd %xmm3,%xmm1
mulsd  %xmm0,%xmm1
divsd  %xmm2,%xmm1
lea    0xe56(%rip),%rdi
movsd  0x8(%rsp),%xmm4
mov    $0x5,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
ret
mov    (%rbx),%rsi
lea    0xd9d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [154 x i8] c"Usage:/%s <width> <height> <angle> of the original image, and the angle want to rotate, then I'll reply with the reduced size of image width and height.\0A\00"
@M_PI = global double 0.000000e+00
@.str.1 = [69 x i8] c"Rotated: w %.0f h %.0f \0AOriginal: width %.0f height %.0f radian %f.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 4
br i1 %15, label %16, label %22
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call double @atof(i8* %25)
store double %26, double* %6
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 2
%29 = load i8*, i8** %28
%30 = call double @atof(i8* %29)
store double %30, double* %7
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 3
%33 = load i8*, i8** %32
%34 = call double @atof(i8* %33)
store double %34, double* %8
%35 = load double, double* %8
%36 = load double, double* @M_PI
%37 = fmul double %35, %36
%38 = fdiv double %37, 1.800000e+02
store double %38, double* %9
%39 = load double, double* %6
%40 = load double, double* %7
%41 = load double, double* %6
%42 = fdiv double %40, %41
%43 = load double, double* %9
%44 = call double @sin(double %43)
%45 = load double, double* %9
%46 = call double @cos(double %45)
%47 = call double @llvm.fmuladd.f64(double %42, double %44, double %46)
%48 = fdiv double %39, %47
store double %48, double* %12
%49 = load double, double* %7
%50 = load double, double* %9
%51 = call double @sin(double %50)
%52 = load double, double* %7
%53 = load double, double* %6
%54 = fdiv double %52, %53
%55 = load double, double* %9
%56 = call double @cos(double %55)
%57 = call double @llvm.fmuladd.f64(double %54, double %56, double %51)
%58 = fdiv double %49, %57
store double %58, double* %13
%59 = load double, double* %12
%60 = load double, double* %13
%61 = fcmp olt double %59, %60
br i1 %61, label %62, label %64
62: ; preds = %22
%63 = load double, double* %12
br label %66
64: ; preds = %22
%65 = load double, double* %13
br label %66
66: ; preds = %64, %62
%67 = phi double [ %63, %62 ], [ %65, %64 ]
store double %67, double* %10
%68 = load double, double* %10
%69 = load double, double* %7
%70 = fmul double %68, %69
%71 = load double, double* %6
%72 = fdiv double %70, %71
store double %72, double* %11
%73 = load double, double* %10
%74 = load double, double* %11
%75 = load double, double* %6
%76 = load double, double* %7
%77 = load double, double* %9
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.1, i64 0, i64 0), double %73, double %74, double %75, double %76, double %77)
ret i32 0
}

LLVM IR (-O2):
@.str = [154 x i8] c"Usage:/%s <width> <height> <angle> of the original image, and the angle want to rotate, then I'll reply with the reduced size of image width and height.\0A\00"
@M_PI = global double 0.000000e+00
@.str.1 = [69 x i8] c"Rotated: w %.0f h %.0f \0AOriginal: width %.0f height %.0f radian %f.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([154 x i8], [154 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call double @atof(i8* %10)
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = tail call double @atof(i8* %13)
%15 = getelementptr inbounds i8*, i8** %1, i64 3
%16 = load i8*, i8** %15
%17 = tail call double @atof(i8* %16)
%18 = load double, double* @M_PI
%19 = fmul double %17, %18
%20 = fdiv double %19, 1.800000e+02
%21 = fdiv double %14, %11
%22 = tail call double @sin(double %20)
%23 = tail call double @cos(double %20)
%24 = tail call double @sin(double %20)
%25 = tail call double @cos(double %20)
%26 = insertelement <2 x double> poison, double %21, i64 0
%27 = shufflevector <2 x double> %26, <2 x double> poison, <2 x i32> zeroinitializer
%28 = insertelement <2 x double> poison, double %22, i64 0
%29 = insertelement <2 x double> %28, double %25, i64 1
%30 = insertelement <2 x double> poison, double %23, i64 0
%31 = insertelement <2 x double> %30, double %24, i64 1
%32 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %27, <2 x double> %29, <2 x double> %31)
%33 = insertelement <2 x double> poison, double %11, i64 0
%34 = insertelement <2 x double> %33, double %14, i64 1
%35 = fdiv <2 x double> %34, %32
%36 = extractelement <2 x double> %35, i64 0
%37 = extractelement <2 x double> %35, i64 1
%38 = fcmp olt double %36, %37
%39 = select i1 %38, double %36, double %37
%40 = fmul double %14, %39
%41 = fdiv double %40, %11
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @.str.1, i64 0, i64 0), double %39, double %41, double %11, double %14, double %20)
ret i32 0
}