#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 */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
int do_field(const char *field, unsigned size, unsigned cur_size,
             unsigned offset, unsigned cur_offset) {
  if (size != cur_size) {
    printf("error: %s size %u should be %u\n", field, cur_size, size);
    exit(1);
  }
  if (offset != cur_offset) {
    printf("error: %s offset %u should be %u\n", field, cur_offset, offset);
    exit(1);
  }
  printf("%8d %-30s %3u\n", offset, field, size);
  return offset + size;
}


x86 assembly (clang, -O0):
<do_field>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
je     1167 <do_field+0x47>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
je     1195 <do_field+0x75>
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
mov    -0x14(%rbp),%esi
mov    -0x8(%rbp),%rdx
mov    -0xc(%rbp),%ecx
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_field>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rax
cmp    %edx,%esi
jne    1153 <do_field+0x33>
mov    %ecx,%ebx
cmp    %r8d,%ecx
jne    1161 <do_field+0x41>
lea    0xf08(%rip),%rdi
mov    %ebx,%esi
mov    %rax,%rdx
mov    %ebp,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
add    %ebp,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xea6(%rip),%rdi
mov    %rax,%rsi
mov    %ebp,%ecx
jmp    1170 <do_field+0x50>
lea    0xeb8(%rip),%rdi
mov    %rax,%rsi
mov    %r8d,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [32 x i8] c"error: %s size %u should be %u\0A\00"
@.str.1 = [34 x i8] c"error: %s offset %u should be %u\0A\00"
@.str.2 = [15 x i8] c"%8d %-30s %3u\0A\00"
define i32 @do_field(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%11 = load i32, i32* %7
%12 = load i32, i32* %8
%13 = icmp ne i32 %11, %12
br i1 %13, label %14, label %20
14: ; preds = %5
%15 = load i8*, i8** %6
%16 = load i32, i32* %8
%17 = load i32, i32* %7
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %15, i32 %16, i32 %17)
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %5
%21 = load i32, i32* %9
%22 = load i32, i32* %10
%23 = icmp ne i32 %21, %22
br i1 %23, label %24, label %30
24: ; preds = %20
%25 = load i8*, i8** %6
%26 = load i32, i32* %10
%27 = load i32, i32* %9
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* %25, i32 %26, i32 %27)
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %20
%31 = load i32, i32* %9
%32 = load i8*, i8** %6
%33 = load i32, i32* %7
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %31, i8* %32, i32 %33)
%35 = load i32, i32* %9
%36 = load i32, i32* %7
%37 = add i32 %35, %36
ret i32 %37
}

LLVM IR (-O2):
@.str = [32 x i8] c"error: %s size %u should be %u\0A\00"
@.str.1 = [34 x i8] c"error: %s offset %u should be %u\0A\00"
@.str.2 = [15 x i8] c"%8d %-30s %3u\0A\00"
define i32 @do_field(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = icmp eq i32 %1, %2
br i1 %6, label %10, label %7
7: ; preds = %5
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %2, i32 %1)
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %5
%11 = icmp eq i32 %3, %4
br i1 %11, label %15, label %12
12: ; preds = %10
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 %4, i32 %3)
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %10
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %3, i8* %0, i32 %1)
%17 = add i32 %3, %1
ret i32 %17
}