#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ *scathttp(char *, char *, double, double, char *, double,
                             double, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
main() {
  FILE *fp;
  int red;
  char cat[8192];
  if (!(fp = scathttp("http://cfa-www/catalog/scat", "ua2", 10.0, 10.0, "J2000",
                      360.0, 20.0, ""))) {
    fprintf(stderr, "Can't scat catalog\n");
    exit(1);
  }
  while ((red = fread(cat, 1, 8192, fp)) > 0) {
    fwrite(cat, 1, red, stdout);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2020,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaf(%rip),%rdi
lea    0xec4(%rip),%rsi
movsd  0xe88(%rip),%xmm1
lea    0xeb9(%rip),%rdx
movsd  0xe81(%rip),%xmm2
movsd  0xe81(%rip),%xmm3
lea    0xebb(%rip),%rcx
movaps %xmm1,%xmm0
call   1040 <scathttp@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    11cb <main+0x7b>
mov    0x2e2d(%rip),%rax
mov    (%rax),%edi
lea    0xe82(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
jmp    11d0 <main+0x80>
lea    -0x2020(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x2000,%edx
call   1030 <fread@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jle    1218 <main+0xc8>
lea    -0x2020(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    0x2dd1(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1070 <fwrite@plt>
jmp    11d0 <main+0x80>
mov    -0x4(%rbp),%eax
add    $0x2020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x2000,%rsp
lea    0xeb5(%rip),%rdi
lea    0xeca(%rip),%rsi
lea    0xec7(%rip),%rdx
lea    0xed9(%rip),%rcx
movsd  0xe80(%rip),%xmm0
movsd  0xe80(%rip),%xmm2
movsd  0xe80(%rip),%xmm3
movaps %xmm0,%xmm1
call   1040 <scathttp@plt>
test   %rax,%rax
je     120a <main+0xba>
mov    %rax,%r14
mov    %rsp,%rdi
mov    $0x1,%esi
mov    $0x2000,%edx
mov    %rax,%rcx
call   1030 <fread@plt>
test   %eax,%eax
jle    11fb <main+0xab>
mov    0x2e18(%rip),%r15
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r15),%ecx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %eax,%edx
call   1070 <fwrite@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x2000,%edx
mov    %r14,%rcx
call   1030 <fread@plt>
test   %eax,%eax
jg     11d0 <main+0x80>
xor    %eax,%eax
add    $0x2000,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2dcf(%rip),%rax
mov    (%rax),%edi
lea    0xe24(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [28 x i8] c"http://cfa-www/catalog/scat\00"
@.str.1 = [4 x i8] c"ua2\00"
@.str.2 = [6 x i8] c"J2000\00"
@.str.3 = [1 x i8] zeroinitializer
@stderr = global i32 0
@.str.4 = [20 x i8] c"Can't scat catalog\0A\00"
@stdout = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca [8192 x i8]
store i32 0, i32* %1
%5 = call i32* @scathttp(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double 1.000000e+01, double 1.000000e+01, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double 3.600000e+02, double 2.000000e+01, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
store i32* %5, i32** %2
%6 = icmp ne i32* %5, null
br i1 %6, label %11, label %7
7: ; preds = %0
%8 = load i32, i32* @stderr
%9 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%10 = call i32 @exit(i32 1)
unreachable
11: ; preds = %0
br label %12
12: ; preds = %17, %11
%13 = getelementptr inbounds [8192 x i8], [8192 x i8]* %4, i64 0, i64 0
%14 = load i32*, i32** %2
%15 = call i32 @fread(i8* %13, i32 1, i32 8192, i32* %14)
store i32 %15, i32* %3
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %12
%18 = getelementptr inbounds [8192 x i8], [8192 x i8]* %4, i64 0, i64 0
%19 = load i32, i32* %3
%20 = load i32, i32* @stdout
%21 = call i32 @fwrite(i8* %18, i32 1, i32 %19, i32 %20)
br label %12
22: ; preds = %12
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
@.str = [28 x i8] c"http://cfa-www/catalog/scat\00"
@.str.1 = [4 x i8] c"ua2\00"
@.str.2 = [6 x i8] c"J2000\00"
@.str.3 = [1 x i8] zeroinitializer
@stderr = global i32 0
@.str.4 = [20 x i8] c"Can't scat catalog\0A\00"
@stdout = global i32 0
define i32 @main() {
%1 = alloca [8192 x i8]
%2 = getelementptr inbounds [8192 x i8], [8192 x i8]* %1, i64 0, i64 0
%3 = tail call i32* @scathttp(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double 1.000000e+01, double 1.000000e+01, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double 3.600000e+02, double 2.000000e+01, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %8, label %5
5: ; preds = %0
%6 = call i32 @fread(i8* %2, i32 1, i32 8192, i32* %3)
%7 = icmp sgt i32 %6, 0
br i1 %7, label %12, label %18
8: ; preds = %0
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %5, %12
%13 = phi i32 [ %16, %12 ], [ %6, %5 ]
%14 = load i32, i32* @stdout
%15 = call i32 @fwrite(i8* %2, i32 1, i32 %13, i32 %14)
%16 = call i32 @fread(i8* %2, i32 1, i32 8192, i32* %3)
%17 = icmp sgt i32 %16, 0
br i1 %17, label %12, label %18
18: ; preds = %12, %5
ret i32 0
}