#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*/ fread(unsigned int *, int, int, int /*<<< orphan*/ *);
unsigned long get_cipher_size(int /*<<< orphan*/ *);
unsigned int *malloc(unsigned long);
unsigned int *read_ciphertext(FILE *file) {
  long unsigned int number_of_elements = get_cipher_size(file);
  unsigned int *ciphertext =
      malloc(number_of_elements * (sizeof(unsigned int)));
  size_t position = 0;
  unsigned int read_number = 1;
  while (position < number_of_elements) {
    fread(&read_number, sizeof(int), 1, file);
    if (read_number == '\0') {
      ciphertext[position] = '\0';
      return ciphertext;
    }
    ciphertext[position] = read_number;
    position++;
  }
  return ciphertext;
}


x86 assembly (clang, -O0):
<read_ciphertext>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <get_cipher_size@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
shl    $0x2,%rdi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11d3 <read_ciphertext+0xa3>
mov    -0x10(%rbp),%rcx
lea    -0x2c(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmpl   $0x0,-0x2c(%rbp)
jne    11b4 <read_ciphertext+0x84>
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11db <read_ciphertext+0xab>
mov    -0x2c(%rbp),%edx
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1169 <read_ciphertext+0x39>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_ciphertext>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
call   1050 <get_cipher_size@plt>
mov    %rax,%r13
lea    0x0(,%rax,4),%rdi
call   1040 <malloc@plt>
mov    %rax,%r15
movl   $0x1,0xc(%rsp)
test   %r13,%r13
je     11a4 <read_ciphertext+0x74>
xor    %ebx,%ebx
lea    0xc(%rsp),%r12
nopl   0x0(%rax)
mov    %r12,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1030 <fread@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
je     119c <read_ciphertext+0x6c>
mov    %eax,(%r15,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1170 <read_ciphertext+0x40>
jmp    11a4 <read_ciphertext+0x74>
movl   $0x0,(%r15,%rbx,4)
mov    %r15,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32* @read_ciphertext(i32* %0) {
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i64
%5 = alloca i32*
%6 = alloca i64
%7 = alloca i32
store i32* %0, i32** %3
%8 = load i32*, i32** %3
%9 = call i64 @get_cipher_size(i32* %8)
store i64 %9, i64* %4
%10 = load i64, i64* %4
%11 = mul i64 %10, 4
%12 = call i32* @malloc(i64 %11)
store i32* %12, i32** %5
store i64 0, i64* %6
store i32 1, i32* %7
br label %13
13: ; preds = %27, %1
%14 = load i64, i64* %6
%15 = load i64, i64* %4
%16 = icmp ult i64 %14, %15
br i1 %16, label %17, label %34
17: ; preds = %13
%18 = load i32*, i32** %3
%19 = call i32 @fread(i32* %7, i32 4, i32 1, i32* %18)
%20 = load i32, i32* %7
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %17
%23 = load i32*, i32** %5
%24 = load i64, i64* %6
%25 = getelementptr inbounds i32, i32* %23, i64 %24
store i32 0, i32* %25
%26 = load i32*, i32** %5
store i32* %26, i32** %2
br label %36
27: ; preds = %17
%28 = load i32, i32* %7
%29 = load i32*, i32** %5
%30 = load i64, i64* %6
%31 = getelementptr inbounds i32, i32* %29, i64 %30
store i32 %28, i32* %31
%32 = load i64, i64* %6
%33 = add i64 %32, 1
store i64 %33, i64* %6
br label %13
34: ; preds = %13
%35 = load i32*, i32** %5
store i32* %35, i32** %2
br label %36
36: ; preds = %34, %22
%37 = load i32*, i32** %2
ret i32* %37
}

LLVM IR (-O2):
define noalias i32* @read_ciphertext(i32* %0) {
%2 = alloca i32
%3 = tail call i64 @get_cipher_size(i32* %0)
%4 = shl i64 %3, 2
%5 = tail call i32* @malloc(i64 %4)
%6 = bitcast i32* %2 to i8*
store i32 1, i32* %2
%7 = icmp eq i64 %3, 0
br i1 %7, label %18, label %8
8: ; preds = %1, %15
%9 = phi i64 [ %16, %15 ], [ 0, %1 ]
%10 = call i32 @fread(i32* %2, i32 4, i32 1, i32* %0)
%11 = load i32, i32* %2
%12 = icmp eq i32 %11, 0
%13 = getelementptr inbounds i32, i32* %5, i64 %9
br i1 %12, label %14, label %15
14: ; preds = %8
store i32 0, i32* %13
br label %18
15: ; preds = %8
store i32 %11, i32* %13
%16 = add nuw i64 %9, 1
%17 = icmp eq i64 %16, %3
br i1 %17, label %18, label %8
18: ; preds = %15, %1, %14
ret i32* %5
}