#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*/ test_v;
struct gf {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, unsigned int,
                           unsigned int, unsigned int, unsigned int);
unsigned int gf_mult(struct gf *, unsigned int, unsigned int);
int /*<<< orphan*/ stderr;
void test_field_lc(struct gf *f) {
  struct test1 {
    unsigned int a;
    unsigned int b;
    unsigned int a_by_b;
  };
  static struct test1 test_v[] = {
      {0, 0, 0},       {0, 1, 0},    {1, 0, 0},   {1, 1, 1}, {0, 2, 0},
      {2, 0, 0},       {1, 2, 2},    {2, 1, 2},   {2, 2, 4}, {0x47, 2, 0x8e},
      {0x8e, 1, 0x8e}, {0x8e, 2, 1}, {0x8e, 4, 2}};
  struct test1 *p;
  int error = 0;
  int i;
  unsigned int res;
  p = test_v;
  for (i = 0; i < sizeof(test_v) / sizeof(struct test1); i++) {
    res = gf_mult(f, p->a, p->b);
    if (res != p->a_by_b) {
      fprintf(stderr,
              "tester"
              ": "
              "gf_mult(0x%x, 0x%x) expected 0x%x actual 0x%x\n",
              p->a, p->b, p->a_by_b, res);
      error = 1;
    }
    p++;
  }
  if (error)
    exit(1);
}


x86 assembly (clang, -O0):
<test_field_lc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0x2ef6(%rip),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movslq -0x18(%rbp),%rax
cmp    $0xd,%rax
jae    11db <test_field_lc+0xab>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edx
call   1050 <gf_mult@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    0x8(%rcx),%eax
je     11c1 <test_field_lc+0x91>
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%r8d
mov    -0x1c(%rbp),%r9d
lea    0xe4b(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%rax
add    $0xc,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1155 <test_field_lc+0x25>
cmpl   $0x0,-0x14(%rbp)
je     11ef <test_field_lc+0xbf>
mov    $0x1,%edi
call   1040 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_field_lc>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
mov    $0x1,%r13b
xor    %ebp,%ebp
lea    0xeb6(%rip),%rbx
mov    0x2e8f(%rip),%r12
lea    0xf44(%rip),%r14
jmp    117d <test_field_lc+0x4d>
nopw   0x0(%rax,%rax,1)
mov    (%r12),%edi
mov    -0xc(%rbx),%edx
mov    -0x8(%rbx),%ecx
mov    %r14,%rsi
mov    %eax,%r9d
call   1030 <fprintf@plt>
xor    %r13d,%r13d
cmp    $0xd,%ebp
je     11c8 <test_field_lc+0x98>
add    $0xc,%rbx
add    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    -0xc(%rbx),%esi
mov    -0x8(%rbx),%edx
mov    %r15,%rdi
call   1050 <gf_mult@plt>
mov    -0x4(%rbx),%r8d
cmp    %r8d,%eax
jne    1160 <test_field_lc+0x30>
add    $0xc,%rbx
add    $0x1,%ebp
cmp    $0xe,%ebp
jne    1190 <test_field_lc+0x60>
test   $0x1,%r13b
je     11c8 <test_field_lc+0x98>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
%struct.test1 = type { i32, i32, i32 }
%struct.gf = type { i32 }
@test_field_lc.test_v = internal global [13 x %struct.test1] [%struct.test1 zeroinitializer, %struct.test1 { i32 0, i32 1, i32 0 }, %struct.test1 { i32 1, i32 0, i32 0 }, %struct.test1 { i32 1, i32 1, i32 1 }, %struct.test1 { i32 0, i32 2, i32 0 }, %struct.test1 { i32 2, i32 0, i32 0 }, %struct.test1 { i32 1, i32 2, i32 2 }, %struct.test1 { i32 2, i32 1, i32 2 }, %struct.test1 { i32 2, i32 2, i32 4 }, %struct.test1 { i32 71, i32 2, i32 142 }, %struct.test1 { i32 142, i32 1, i32 142 }, %struct.test1 { i32 142, i32 2, i32 1 }, %struct.test1 { i32 142, i32 4, i32 2 }]
@stderr = global i32 0
@.str = [55 x i8] c"tester: gf_mult(0x%x, 0x%x) expected 0x%x actual 0x%x\0A\00"
define void @test_field_lc(%struct.gf* %0) {
%2 = alloca %struct.gf*
%3 = alloca %struct.test1*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store %struct.gf* %0, %struct.gf** %2
store i32 0, i32* %4
store %struct.test1* getelementptr inbounds ([13 x %struct.test1], [13 x %struct.test1]* @test_field_lc.test_v, i64 0, i64 0), %struct.test1** %3
store i32 0, i32* %5
br label %7
7: ; preds = %41, %1
%8 = load i32, i32* %5
%9 = sext i32 %8 to i64
%10 = icmp ult i64 %9, 13
br i1 %10, label %11, label %44
11: ; preds = %7
%12 = load %struct.gf*, %struct.gf** %2
%13 = load %struct.test1*, %struct.test1** %3
%14 = getelementptr inbounds %struct.test1, %struct.test1* %13, i32 0, i32 0
%15 = load i32, i32* %14
%16 = load %struct.test1*, %struct.test1** %3
%17 = getelementptr inbounds %struct.test1, %struct.test1* %16, i32 0, i32 1
%18 = load i32, i32* %17
%19 = call i32 @gf_mult(%struct.gf* %12, i32 %15, i32 %18)
store i32 %19, i32* %6
%20 = load i32, i32* %6
%21 = load %struct.test1*, %struct.test1** %3
%22 = getelementptr inbounds %struct.test1, %struct.test1* %21, i32 0, i32 2
%23 = load i32, i32* %22
%24 = icmp ne i32 %20, %23
br i1 %24, label %25, label %38
25: ; preds = %11
%26 = load i32, i32* @stderr
%27 = load %struct.test1*, %struct.test1** %3
%28 = getelementptr inbounds %struct.test1, %struct.test1* %27, i32 0, i32 0
%29 = load i32, i32* %28
%30 = load %struct.test1*, %struct.test1** %3
%31 = getelementptr inbounds %struct.test1, %struct.test1* %30, i32 0, i32 1
%32 = load i32, i32* %31
%33 = load %struct.test1*, %struct.test1** %3
%34 = getelementptr inbounds %struct.test1, %struct.test1* %33, i32 0, i32 2
%35 = load i32, i32* %34
%36 = load i32, i32* %6
%37 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i32 %29, i32 %32, i32 %35, i32 %36)
store i32 1, i32* %4
br label %38
38: ; preds = %25, %11
%39 = load %struct.test1*, %struct.test1** %3
%40 = getelementptr inbounds %struct.test1, %struct.test1* %39, i32 1
store %struct.test1* %40, %struct.test1** %3
br label %41
41: ; preds = %38
%42 = load i32, i32* %5
%43 = add nsw i32 %42, 1
store i32 %43, i32* %5
br label %7
44: ; preds = %7
%45 = load i32, i32* %4
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %44
%48 = call i32 @exit(i32 1)
unreachable
49: ; preds = %44
ret void
}

LLVM IR (-O2):
%struct.test1 = type { i32, i32, i32 }
%struct.gf = type { i32 }
@test_field_lc.test_v = internal unnamed_addr constant [13 x %struct.test1] [%struct.test1 zeroinitializer, %struct.test1 { i32 0, i32 1, i32 0 }, %struct.test1 { i32 1, i32 0, i32 0 }, %struct.test1 { i32 1, i32 1, i32 1 }, %struct.test1 { i32 0, i32 2, i32 0 }, %struct.test1 { i32 2, i32 0, i32 0 }, %struct.test1 { i32 1, i32 2, i32 2 }, %struct.test1 { i32 2, i32 1, i32 2 }, %struct.test1 { i32 2, i32 2, i32 4 }, %struct.test1 { i32 71, i32 2, i32 142 }, %struct.test1 { i32 142, i32 1, i32 142 }, %struct.test1 { i32 142, i32 2, i32 1 }, %struct.test1 { i32 142, i32 4, i32 2 }]
@stderr = global i32 0
@.str = [55 x i8] c"tester: gf_mult(0x%x, 0x%x) expected 0x%x actual 0x%x\0A\00"
define void @test_field_lc(%struct.gf* %0) {
br label %2
2: ; preds = %21, %1
%3 = phi %struct.test1* [ %28, %21 ], [ getelementptr inbounds ([13 x %struct.test1], [13 x %struct.test1]* @test_field_lc.test_v, i64 0, i64 0), %1 ]
%4 = phi i32 [ %29, %21 ], [ 0, %1 ]
%5 = phi i1 [ false, %21 ], [ true, %1 ]
br label %6
6: ; preds = %2, %17
%7 = phi %struct.test1* [ %18, %17 ], [ %3, %2 ]
%8 = phi i32 [ %19, %17 ], [ %4, %2 ]
%9 = getelementptr inbounds %struct.test1, %struct.test1* %7, i64 0, i32 0
%10 = load i32, i32* %9
%11 = getelementptr inbounds %struct.test1, %struct.test1* %7, i64 0, i32 1
%12 = load i32, i32* %11
%13 = tail call i32 @gf_mult(%struct.gf* %0, i32 %10, i32 %12)
%14 = getelementptr inbounds %struct.test1, %struct.test1* %7, i64 0, i32 2
%15 = load i32, i32* %14
%16 = icmp eq i32 %13, %15
br i1 %16, label %17, label %21
17: ; preds = %6
%18 = getelementptr inbounds %struct.test1, %struct.test1* %7, i64 1
%19 = add nuw nsw i32 %8, 1
%20 = icmp eq i32 %19, 13
br i1 %20, label %31, label %6
21: ; preds = %6
%22 = getelementptr inbounds %struct.test1, %struct.test1* %7, i64 0, i32 0
%23 = getelementptr inbounds %struct.test1, %struct.test1* %7, i64 0, i32 1
%24 = load i32, i32* @stderr
%25 = load i32, i32* %22
%26 = load i32, i32* %23
%27 = tail call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i32 %25, i32 %26, i32 %15, i32 %13)
%28 = getelementptr inbounds %struct.test1, %struct.test1* %7, i64 1
%29 = add nuw nsw i32 %8, 1
%30 = icmp eq i32 %29, 13
br i1 %30, label %32, label %2
31: ; preds = %17
br i1 %5, label %34, label %32
32: ; preds = %21, %31
%33 = tail call i32 @exit(i32 1)
unreachable
34: ; preds = %31
ret void
}