#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*/ printf(char *, int, ...);
int do_field(const char *field, size_t size, int offset, int cur_offset) {
  if (offset != cur_offset) {
    printf("\t(padding %d bytes?)\n", offset - cur_offset);
  }
  printf("%8d %-30s %3u\n", offset, field, (unsigned)size);
  return offset + size;
}


x86 assembly (clang, -O0):
<do_field>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
je     1146 <do_field+0x36>
mov    -0x14(%rbp),%esi
sub    -0x18(%rbp),%esi
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    %eax,%ecx
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x14(%rbp),%rax
add    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_field>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %edx,%esi
sub    %ecx,%esi
je     1130 <do_field+0x20>
lea    0xed7(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xedf(%rip),%rdi
mov    %ebp,%esi
mov    %r14,%rdx
mov    %ebx,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
add    %ebp,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"\09(padding %d bytes?)\0A\00"
@.str.1 = [15 x i8] c"%8d %-30s %3u\0A\00"
define i32 @do_field(i8* %0, i64 %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %5
store i64 %1, i64* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i32, i32* %7
%10 = load i32, i32* %8
%11 = icmp ne i32 %9, %10
br i1 %11, label %12, label %17
12: ; preds = %4
%13 = load i32, i32* %7
%14 = load i32, i32* %8
%15 = sub nsw i32 %13, %14
%16 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %12, %4
%18 = load i32, i32* %7
%19 = load i8*, i8** %5
%20 = load i64, i64* %6
%21 = trunc i64 %20 to i32
%22 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %18, i8* %19, i32 %21)
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = load i64, i64* %6
%26 = add i64 %24, %25
%27 = trunc i64 %26 to i32
ret i32 %27
}

LLVM IR (-O2):
@.str = [22 x i8] c"\09(padding %d bytes?)\0A\00"
@.str.1 = [15 x i8] c"%8d %-30s %3u\0A\00"
define i32 @do_field(i8* %0, i64 %1, i32 %2, i32 %3) {
%5 = icmp eq i32 %2, %3
br i1 %5, label %9, label %6
6: ; preds = %4
%7 = sub nsw i32 %2, %3
%8 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %7)
br label %9
9: ; preds = %6, %4
%10 = trunc i64 %1 to i32
%11 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %2, i8* %0, i32 %10)
%12 = add i32 %10, %2
ret i32 %12
}