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

/* Variables and functions */
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ assert(int);
int fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fmemopen(char *, int, char *);
size_t fread(char *, int, int, int /*<<< orphan*/ *);
int fseek(int /*<<< orphan*/ *, int /*<<< orphan*/, int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
size_t fwrite(char *, int, int, int /*<<< orphan*/ *);
scalar_t__ strncmp(char *, char *, int);
void test_data_length() {
  FILE *fp;
  char buf[512] = {'\0'};
  char str[] = "Test data length. ";
  char str2[] = "Do we have two sentences?";
  char str3[sizeof(str) + sizeof(str2) - 1];
  long pos;
  size_t nofw, nofr;
  int rc;
  fp = fmemopen(buf, sizeof(buf), "w+");
  assert(fp != NULL);
  nofw = fwrite(str, 1, sizeof(str), fp);
  assert(nofw == sizeof(str));
  rc = fseek(fp, 0, SEEK_END);
  assert(rc == 0);
  pos = ftell(fp);
  assert(pos == sizeof(str));
  rc = fclose(fp);
  assert(rc == 0);
  fp = fmemopen(buf, sizeof(buf), "a+");
  assert(fp != NULL);
  nofw = fwrite(str2, 1, sizeof(str2), fp);
  assert(nofw == sizeof(str2));
  rc = fseek(fp, 0, SEEK_SET);
  assert(rc == 0);
  pos = ftell(fp);
  assert(pos == 0);
  nofr = fread(str3, 1, sizeof(buf), fp);
  assert(nofr == sizeof(str3));
  assert(strncmp(str3, str, sizeof(str) - 1) == 0);
  assert(strncmp(str3 + sizeof(str) - 1, str2, sizeof(str2)) == 0);
  rc = fclose(fp);
  assert(rc == 0);
}


x86 assembly (clang, -O0):
<test_data_length>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2a0,%rsp
lea    -0x210(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1070 <memset@plt>
mov    0xe4b(%rip),%rax
mov    %rax,-0x230(%rbp)
mov    0xe45(%rip),%rax
mov    %rax,-0x228(%rbp)
mov    0xe3f(%rip),%ax
mov    %ax,-0x220(%rbp)
mov    0xe34(%rip),%al
mov    %al,-0x21e(%rbp)
mov    0xe35(%rip),%rax
mov    %rax,-0x250(%rbp)
mov    0xe2f(%rip),%rax
mov    %rax,-0x248(%rbp)
mov    0xe29(%rip),%rax
mov    %rax,-0x240(%rbp)
mov    0xe23(%rip),%ax
mov    %ax,-0x238(%rbp)
lea    -0x210(%rbp),%rdi
mov    $0x200,%esi
lea    0xe0b(%rip),%rdx
call   1040 <fmemopen@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
lea    -0x230(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
mov    $0x13,%edx
call   10b0 <fwrite@plt>
mov    %rax,-0x290(%rbp)
cmpq   $0x13,-0x290(%rbp)
13
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    -0x8(%rbp),%rdi
mov    0x2d5d(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10a0 <fseek@plt>
mov    %eax,-0x29c(%rbp)
cmpl   $0x0,-0x29c(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    -0x8(%rbp),%rdi
call   1090 <ftell@plt>
mov    %rax,-0x288(%rbp)
cmpq   $0x13,-0x288(%rbp)
13
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    -0x8(%rbp),%rdi
call   1060 <fclose@plt>
mov    %eax,-0x29c(%rbp)
cmpl   $0x0,-0x29c(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
lea    -0x210(%rbp),%rdi
mov    $0x200,%esi
lea    0xd34(%rip),%rdx
call   1040 <fmemopen@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
lea    -0x250(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
mov    $0x1a,%edx
call   10b0 <fwrite@plt>
mov    %rax,-0x290(%rbp)
cmpq   $0x1a,-0x290(%rbp)
1a
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    -0x8(%rbp),%rdi
mov    0x2c73(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10a0 <fseek@plt>
mov    %eax,-0x29c(%rbp)
cmpl   $0x0,-0x29c(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    -0x8(%rbp),%rdi
call   1090 <ftell@plt>
mov    %rax,-0x288(%rbp)
cmpq   $0x0,-0x288(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
lea    -0x280(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
mov    $0x200,%edx
call   1050 <fread@plt>
mov    %rax,-0x298(%rbp)
cmpq   $0x2c,-0x298(%rbp)
2c
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
lea    -0x280(%rbp),%rdi
lea    -0x230(%rbp),%rsi
mov    $0x12,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
lea    -0x280(%rbp),%rdi
add    $0x13,%rdi
add    $0xffffffffffffffff,%rdi
lea    -0x250(%rbp),%rsi
mov    $0x1a,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    -0x8(%rbp),%rdi
call   1060 <fclose@plt>
mov    %eax,-0x29c(%rbp)
cmpl   $0x0,-0x29c(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
add    $0x2a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_data_length>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x278,%rsp
lea    0x70(%rsp),%r15
mov    $0x200,%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1070 <memset@plt>
movaps 0xe47(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x202e68,0xf(%rsp)
movups 0xe5e(%rip),%xmm0
movups %xmm0,0x2a(%rsp)
movaps 0xe48(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
lea    0xe56(%rip),%rdx
mov    %r15,%rdi
mov    $0x200,%esi
call   1040 <fmemopen@plt>
mov    %rax,%rbx
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1080 <assert@plt>
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x13,%edx
mov    %rbx,%rcx
call   10b0 <fwrite@plt>
xor    %edi,%edi
cmp    $0x13,%rax
sete   %dil
call   1080 <assert@plt>
mov    0x2db8(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   10a0 <fseek@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1080 <assert@plt>
mov    %rbx,%rdi
call   1090 <ftell@plt>
xor    %edi,%edi
cmp    $0x13,%rax
sete   %dil
call   1080 <assert@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1080 <assert@plt>
lea    0xdc1(%rip),%rdx
mov    %r15,%rdi
mov    $0x200,%esi
call   1040 <fmemopen@plt>
mov    %rax,%rbx
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1080 <assert@plt>
lea    0x20(%rsp),%r15
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x1a,%edx
mov    %rbx,%rcx
call   10b0 <fwrite@plt>
xor    %edi,%edi
cmp    $0x1a,%rax
sete   %dil
call   1080 <assert@plt>
mov    0x2d0e(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   10a0 <fseek@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1080 <assert@plt>
mov    %rbx,%rdi
call   1090 <ftell@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1080 <assert@plt>
lea    0x40(%rsp),%r12
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x200,%edx
mov    %rbx,%rcx
call   1050 <fread@plt>
xor    %edi,%edi
cmp    $0x2c,%rax
sete   %dil
call   1080 <assert@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    $0x12,%edx
call   1030 <strncmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1080 <assert@plt>
lea    0x52(%rsp),%rdi
mov    %r15,%rsi
mov    $0x1a,%edx
call   1030 <strncmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1080 <assert@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1080 <assert@plt>
add    $0x278,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.test_data_length.str = [19 x i8] c"Test data length. \00"
@__const.test_data_length.str2 = [26 x i8] c"Do we have two sentences?\00"
@.str = [3 x i8] c"w+\00"
@SEEK_END = global i32 0
@.str.1 = [3 x i8] c"a+\00"
@SEEK_SET = global i32 0
define void @test_data_length() {
%1 = alloca i32*
%2 = alloca [512 x i8]
%3 = alloca [19 x i8]
%4 = alloca [26 x i8]
%5 = alloca [44 x i8]
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32
%10 = bitcast [512 x i8]* %2 to i8*
%11 = bitcast [19 x i8]* %3 to i8*
%12 = bitcast [26 x i8]* %4 to i8*
%13 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%14 = call i32* @fmemopen(i8* %13, i32 512, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %1
%15 = load i32*, i32** %1
%16 = icmp ne i32* %15, null
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = getelementptr inbounds [19 x i8], [19 x i8]* %3, i64 0, i64 0
%20 = load i32*, i32** %1
%21 = call i64 @fwrite(i8* %19, i32 1, i32 19, i32* %20)
store i64 %21, i64* %7
%22 = load i64, i64* %7
%23 = icmp eq i64 %22, 19
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = load i32*, i32** %1
%27 = load i32, i32* @SEEK_END
%28 = call i32 @fseek(i32* %26, i32 0, i32 %27)
store i32 %28, i32* %9
%29 = load i32, i32* %9
%30 = icmp eq i32 %29, 0
%31 = zext i1 %30 to i32
%32 = call i32 @assert(i32 %31)
%33 = load i32*, i32** %1
%34 = call i64 @ftell(i32* %33)
store i64 %34, i64* %6
%35 = load i64, i64* %6
%36 = icmp eq i64 %35, 19
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
%39 = load i32*, i32** %1
%40 = call i32 @fclose(i32* %39)
store i32 %40, i32* %9
%41 = load i32, i32* %9
%42 = icmp eq i32 %41, 0
%43 = zext i1 %42 to i32
%44 = call i32 @assert(i32 %43)
%45 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%46 = call i32* @fmemopen(i8* %45, i32 512, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %46, i32** %1
%47 = load i32*, i32** %1
%48 = icmp ne i32* %47, null
%49 = zext i1 %48 to i32
%50 = call i32 @assert(i32 %49)
%51 = getelementptr inbounds [26 x i8], [26 x i8]* %4, i64 0, i64 0
%52 = load i32*, i32** %1
%53 = call i64 @fwrite(i8* %51, i32 1, i32 26, i32* %52)
store i64 %53, i64* %7
%54 = load i64, i64* %7
%55 = icmp eq i64 %54, 26
%56 = zext i1 %55 to i32
%57 = call i32 @assert(i32 %56)
%58 = load i32*, i32** %1
%59 = load i32, i32* @SEEK_SET
%60 = call i32 @fseek(i32* %58, i32 0, i32 %59)
store i32 %60, i32* %9
%61 = load i32, i32* %9
%62 = icmp eq i32 %61, 0
%63 = zext i1 %62 to i32
%64 = call i32 @assert(i32 %63)
%65 = load i32*, i32** %1
%66 = call i64 @ftell(i32* %65)
store i64 %66, i64* %6
%67 = load i64, i64* %6
%68 = icmp eq i64 %67, 0
%69 = zext i1 %68 to i32
%70 = call i32 @assert(i32 %69)
%71 = getelementptr inbounds [44 x i8], [44 x i8]* %5, i64 0, i64 0
%72 = load i32*, i32** %1
%73 = call i64 @fread(i8* %71, i32 1, i32 512, i32* %72)
store i64 %73, i64* %8
%74 = load i64, i64* %8
%75 = icmp eq i64 %74, 44
%76 = zext i1 %75 to i32
%77 = call i32 @assert(i32 %76)
%78 = getelementptr inbounds [44 x i8], [44 x i8]* %5, i64 0, i64 0
%79 = getelementptr inbounds [19 x i8], [19 x i8]* %3, i64 0, i64 0
%80 = call i64 @strncmp(i8* %78, i8* %79, i32 18)
%81 = icmp eq i64 %80, 0
%82 = zext i1 %81 to i32
%83 = call i32 @assert(i32 %82)
%84 = getelementptr inbounds [44 x i8], [44 x i8]* %5, i64 0, i64 0
%85 = getelementptr inbounds i8, i8* %84, i64 19
%86 = getelementptr inbounds i8, i8* %85, i64 -1
%87 = getelementptr inbounds [26 x i8], [26 x i8]* %4, i64 0, i64 0
%88 = call i64 @strncmp(i8* %86, i8* %87, i32 26)
%89 = icmp eq i64 %88, 0
%90 = zext i1 %89 to i32
%91 = call i32 @assert(i32 %90)
%92 = load i32*, i32** %1
%93 = call i32 @fclose(i32* %92)
store i32 %93, i32* %9
%94 = load i32, i32* %9
%95 = icmp eq i32 %94, 0
%96 = zext i1 %95 to i32
%97 = call i32 @assert(i32 %96)
ret void
}

LLVM IR (-O2):
@__const.test_data_length.str = [19 x i8] c"Test data length. \00"
@__const.test_data_length.str2 = [26 x i8] c"Do we have two sentences?\00"
@.str = [3 x i8] c"w+\00"
@SEEK_END = global i32 0
@.str.1 = [3 x i8] c"a+\00"
@SEEK_SET = global i32 0
define void @test_data_length() {
%1 = alloca [512 x i8]
%2 = alloca [19 x i8]
%3 = alloca [26 x i8]
%4 = alloca [44 x i8]
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [19 x i8], [19 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [26 x i8], [26 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [44 x i8], [44 x i8]* %4, i64 0, i64 0
%9 = call i32* @fmemopen(i8* %5, i32 512, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%10 = icmp ne i32* %9, null
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = call i64 @fwrite(i8* %6, i32 1, i32 19, i32* %9)
%14 = icmp eq i64 %13, 19
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = load i32, i32* @SEEK_END
%18 = call i32 @fseek(i32* %9, i32 0, i32 %17)
%19 = icmp eq i32 %18, 0
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = call i64 @ftell(i32* %9)
%23 = icmp eq i64 %22, 19
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = call i32 @fclose(i32* %9)
%27 = icmp eq i32 %26, 0
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
%30 = call i32* @fmemopen(i8* %5, i32 512, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%31 = icmp ne i32* %30, null
%32 = zext i1 %31 to i32
%33 = call i32 @assert(i32 %32)
%34 = call i64 @fwrite(i8* %7, i32 1, i32 26, i32* %30)
%35 = icmp eq i64 %34, 26
%36 = zext i1 %35 to i32
%37 = call i32 @assert(i32 %36)
%38 = load i32, i32* @SEEK_SET
%39 = call i32 @fseek(i32* %30, i32 0, i32 %38)
%40 = icmp eq i32 %39, 0
%41 = zext i1 %40 to i32
%42 = call i32 @assert(i32 %41)
%43 = call i64 @ftell(i32* %30)
%44 = icmp eq i64 %43, 0
%45 = zext i1 %44 to i32
%46 = call i32 @assert(i32 %45)
%47 = call i64 @fread(i8* %8, i32 1, i32 512, i32* %30)
%48 = icmp eq i64 %47, 44
%49 = zext i1 %48 to i32
%50 = call i32 @assert(i32 %49)
%51 = call i64 @strncmp(i8* %8, i8* %6, i32 18)
%52 = icmp eq i64 %51, 0
%53 = zext i1 %52 to i32
%54 = call i32 @assert(i32 %53)
%55 = getelementptr inbounds [44 x i8], [44 x i8]* %4, i64 0, i64 18
%56 = call i64 @strncmp(i8* %55, i8* %7, i32 26)
%57 = icmp eq i64 %56, 0
%58 = zext i1 %57 to i32
%59 = call i32 @assert(i32 %58)
%60 = call i32 @fclose(i32* %30)
%61 = icmp eq i32 %60, 0
%62 = zext i1 %61 to i32
%63 = call i32 @assert(i32 %62)
ret void
}