#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*/ adjust_pdb_field_string(char *);
int /*<<< orphan*/ get_pdb_coordinates(char const *, float *, float *, float *,
                                       float *, float *);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int /*<<< orphan*/ strncpy(char *, char const *, int);
void get_pdb_fields(const char *record, int reclength, int *serial, char *name,
                    char *resname, char *chain, char *segname, char *resid,
                    char *insertion, char *altloc, char *elementsymbol,
                    float *x, float *y, float *z, float *occup, float *beta) {
  char serialbuf[6];
  strncpy(serialbuf, record + 6, 5);
  serialbuf[5] = '\0';
  *serial = 0;
  sscanf(serialbuf, "%5d", serial);
  strncpy(name, record + 12, 4);
  name[4] = '\0';
  adjust_pdb_field_string(name);
  strncpy(altloc, record + 16, 1);
  altloc[1] = '\0';
  strncpy(resname, record + 17, 4);
  resname[4] = '\0';
  adjust_pdb_field_string(resname);
  chain[0] = record[21];
  chain[1] = '\0';
  strncpy(resid, record + 22, 4);
  resid[4] = '\0';
  adjust_pdb_field_string(resid);
  insertion[0] = record[26];
  insertion[1] = '\0';
  get_pdb_coordinates(record, x, y, z, occup, beta);
  if (reclength >= 73) {
    strncpy(segname, record + 72, 4);
    segname[4] = '\0';
    adjust_pdb_field_string(segname);
  } else {
    segname[0] = '\0';
  }
  if (reclength >= 77) {
    strncpy(elementsymbol, record + 76, 2);
    elementsymbol[2] = '\0';
  } else {
    elementsymbol[0] = '\0';
  }
}


x86 assembly (clang, -O0):
<get_pdb_fields>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x58(%rbp),%rax
mov    0x50(%rbp),%rax
mov    0x48(%rbp),%rax
mov    0x40(%rbp),%rax
mov    0x38(%rbp),%rax
mov    0x30(%rbp),%rax
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
lea    -0x36(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x6,%rsi
mov    $0x5,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0x31(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
lea    -0x36(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe46(%rip),%rsi
call   1050 <sscanf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0xc,%rsi
mov    $0x4,%edx
call   1030 <strncpy@plt>
mov    -0x20(%rbp),%rax
movb   $0x0,0x4(%rax)
mov    -0x20(%rbp),%rdi
call   1060 <adjust_pdb_field_string@plt>
mov    0x28(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x10,%rsi
mov    $0x1,%edx
call   1030 <strncpy@plt>
mov    0x28(%rbp),%rax
movb   $0x0,0x1(%rax)
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x11,%rsi
mov    $0x4,%edx
call   1030 <strncpy@plt>
mov    -0x28(%rbp),%rax
movb   $0x0,0x4(%rax)
mov    -0x28(%rbp),%rdi
call   1060 <adjust_pdb_field_string@plt>
mov    -0x8(%rbp),%rax
mov    0x15(%rax),%cl
mov    -0x30(%rbp),%rax
mov    %cl,(%rax)
mov    -0x30(%rbp),%rax
movb   $0x0,0x1(%rax)
mov    0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x16,%rsi
mov    $0x4,%edx
call   1030 <strncpy@plt>
mov    0x18(%rbp),%rax
movb   $0x0,0x4(%rax)
mov    0x18(%rbp),%rdi
call   1060 <adjust_pdb_field_string@plt>
mov    -0x8(%rbp),%rax
mov    0x1a(%rax),%cl
mov    0x20(%rbp),%rax
mov    %cl,(%rax)
mov    0x20(%rbp),%rax
movb   $0x0,0x1(%rax)
mov    -0x8(%rbp),%rdi
mov    0x38(%rbp),%rsi
mov    0x40(%rbp),%rdx
mov    0x48(%rbp),%rcx
mov    0x50(%rbp),%r8
mov    0x58(%rbp),%r9
call   1040 <get_pdb_coordinates@plt>
cmpl   $0x49,-0xc(%rbp)
jl     12cf <get_pdb_fields+0x18f>
mov    0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x48,%rsi
mov    $0x4,%edx
call   1030 <strncpy@plt>
mov    0x10(%rbp),%rax
movb   $0x0,0x4(%rax)
mov    0x10(%rbp),%rdi
call   1060 <adjust_pdb_field_string@plt>
jmp    12d6 <get_pdb_fields+0x196>
mov    0x10(%rbp),%rax
movb   $0x0,(%rax)
cmpl   $0x4d,-0xc(%rbp)
jl     1303 <get_pdb_fields+0x1c3>
mov    0x30(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x4c,%rsi
mov    $0x2,%edx
call   1030 <strncpy@plt>
mov    0x30(%rbp),%rax
movb   $0x0,0x2(%rax)
jmp    130a <get_pdb_fields+0x1ca>
mov    0x30(%rbp),%rax
movb   $0x0,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_pdb_fields>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,0x10(%rsp)
mov    %r8,%r15
mov    %rcx,%r14
mov    %rdx,%r13
mov    %esi,%r12d
mov    %rdi,%rbx
lea    0x6(%rdi),%rsi
lea    0xa(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x5,%edx
call   1030 <strncpy@plt>
movb   $0x0,0xf(%rsp)
movl   $0x0,0x0(%r13)
lea    0xe74(%rip),%rsi
mov    %rbp,%rdi
mov    %r13,%rdx
call   1050 <sscanf@plt>
lea    0xc(%rbx),%rsi
mov    %r14,%rdi
mov    $0x4,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x4(%r14)
mov    %r14,%rdi
call   1060 <adjust_pdb_field_string@plt>
lea    0x10(%rbx),%rsi
mov    0x68(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x1,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x1(%rbp)
lea    0x11(%rbx),%rsi
mov    %r15,%rdi
mov    $0x4,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x4(%r15)
mov    %r15,%rdi
call   1060 <adjust_pdb_field_string@plt>
mov    0x15(%rbx),%al
mov    0x10(%rsp),%rcx
mov    %al,(%rcx)
movb   $0x0,0x1(%rcx)
lea    0x16(%rbx),%rsi
mov    0x58(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x4,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x4(%rbp)
mov    %rbp,%rdi
call   1060 <adjust_pdb_field_string@plt>
mov    0x1a(%rbx),%al
mov    0x60(%rsp),%rcx
mov    %al,(%rcx)
movb   $0x0,0x1(%rcx)
mov    %rbx,%rdi
mov    0x78(%rsp),%rsi
mov    0x80(%rsp),%rdx
mov    0x88(%rsp),%rcx
mov    0x90(%rsp),%r8
mov    0x98(%rsp),%r9
call   1040 <get_pdb_coordinates@plt>
cmp    $0x48,%r12d
jle    12a5 <get_pdb_fields+0x165>
lea    0x48(%rbx),%rsi
mov    0x50(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x4,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x4(%rbp)
mov    %rbp,%rdi
call   1060 <adjust_pdb_field_string@plt>
cmp    $0x4d,%r12d
mov    0x70(%rsp),%rbp
jb     12b2 <get_pdb_fields+0x172>
add    $0x4c,%rbx
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1030 <strncpy@plt>
add    $0x2,%rbp
jmp    12b2 <get_pdb_fields+0x172>
mov    0x50(%rsp),%rax
movb   $0x0,(%rax)
mov    0x70(%rsp),%rbp
movb   $0x0,0x0(%rbp)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%5d\00"
define void @get_pdb_fields(i8* %0, i32 %1, i32* %2, i8* %3, i8* %4, i8* %5, i8* %6, i8* %7, i8* %8, i8* %9, i8* %10, float* %11, float* %12, float* %13, float* %14, float* %15) {
%17 = alloca i8*
%18 = alloca i32
%19 = alloca i32*
%20 = alloca i8*
%21 = alloca i8*
%22 = alloca i8*
%23 = alloca i8*
%24 = alloca i8*
%25 = alloca i8*
%26 = alloca i8*
%27 = alloca i8*
%28 = alloca float*
%29 = alloca float*
%30 = alloca float*
%31 = alloca float*
%32 = alloca float*
%33 = alloca [6 x i8]
store i8* %0, i8** %17
store i32 %1, i32* %18
store i32* %2, i32** %19
store i8* %3, i8** %20
store i8* %4, i8** %21
store i8* %5, i8** %22
store i8* %6, i8** %23
store i8* %7, i8** %24
store i8* %8, i8** %25
store i8* %9, i8** %26
store i8* %10, i8** %27
store float* %11, float** %28
store float* %12, float** %29
store float* %13, float** %30
store float* %14, float** %31
store float* %15, float** %32
%34 = getelementptr inbounds [6 x i8], [6 x i8]* %33, i64 0, i64 0
%35 = load i8*, i8** %17
%36 = getelementptr inbounds i8, i8* %35, i64 6
%37 = call i32 @strncpy(i8* %34, i8* %36, i32 5)
%38 = getelementptr inbounds [6 x i8], [6 x i8]* %33, i64 0, i64 5
store i8 0, i8* %38
%39 = load i32*, i32** %19
store i32 0, i32* %39
%40 = getelementptr inbounds [6 x i8], [6 x i8]* %33, i64 0, i64 0
%41 = load i32*, i32** %19
%42 = call i32 @sscanf(i8* %40, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %41)
%43 = load i8*, i8** %20
%44 = load i8*, i8** %17
%45 = getelementptr inbounds i8, i8* %44, i64 12
%46 = call i32 @strncpy(i8* %43, i8* %45, i32 4)
%47 = load i8*, i8** %20
%48 = getelementptr inbounds i8, i8* %47, i64 4
store i8 0, i8* %48
%49 = load i8*, i8** %20
%50 = call i32 @adjust_pdb_field_string(i8* %49)
%51 = load i8*, i8** %26
%52 = load i8*, i8** %17
%53 = getelementptr inbounds i8, i8* %52, i64 16
%54 = call i32 @strncpy(i8* %51, i8* %53, i32 1)
%55 = load i8*, i8** %26
%56 = getelementptr inbounds i8, i8* %55, i64 1
store i8 0, i8* %56
%57 = load i8*, i8** %21
%58 = load i8*, i8** %17
%59 = getelementptr inbounds i8, i8* %58, i64 17
%60 = call i32 @strncpy(i8* %57, i8* %59, i32 4)
%61 = load i8*, i8** %21
%62 = getelementptr inbounds i8, i8* %61, i64 4
store i8 0, i8* %62
%63 = load i8*, i8** %21
%64 = call i32 @adjust_pdb_field_string(i8* %63)
%65 = load i8*, i8** %17
%66 = getelementptr inbounds i8, i8* %65, i64 21
%67 = load i8, i8* %66
%68 = load i8*, i8** %22
%69 = getelementptr inbounds i8, i8* %68, i64 0
store i8 %67, i8* %69
%70 = load i8*, i8** %22
%71 = getelementptr inbounds i8, i8* %70, i64 1
store i8 0, i8* %71
%72 = load i8*, i8** %24
%73 = load i8*, i8** %17
%74 = getelementptr inbounds i8, i8* %73, i64 22
%75 = call i32 @strncpy(i8* %72, i8* %74, i32 4)
%76 = load i8*, i8** %24
%77 = getelementptr inbounds i8, i8* %76, i64 4
store i8 0, i8* %77
%78 = load i8*, i8** %24
%79 = call i32 @adjust_pdb_field_string(i8* %78)
%80 = load i8*, i8** %17
%81 = getelementptr inbounds i8, i8* %80, i64 26
%82 = load i8, i8* %81
%83 = load i8*, i8** %25
%84 = getelementptr inbounds i8, i8* %83, i64 0
store i8 %82, i8* %84
%85 = load i8*, i8** %25
%86 = getelementptr inbounds i8, i8* %85, i64 1
store i8 0, i8* %86
%87 = load i8*, i8** %17
%88 = load float*, float** %28
%89 = load float*, float** %29
%90 = load float*, float** %30
%91 = load float*, float** %31
%92 = load float*, float** %32
%93 = call i32 @get_pdb_coordinates(i8* %87, float* %88, float* %89, float* %90, float* %91, float* %92)
%94 = load i32, i32* %18
%95 = icmp sge i32 %94, 73
br i1 %95, label %96, label %105
96: ; preds = %16
%97 = load i8*, i8** %23
%98 = load i8*, i8** %17
%99 = getelementptr inbounds i8, i8* %98, i64 72
%100 = call i32 @strncpy(i8* %97, i8* %99, i32 4)
%101 = load i8*, i8** %23
%102 = getelementptr inbounds i8, i8* %101, i64 4
store i8 0, i8* %102
%103 = load i8*, i8** %23
%104 = call i32 @adjust_pdb_field_string(i8* %103)
br label %108
105: ; preds = %16
%106 = load i8*, i8** %23
%107 = getelementptr inbounds i8, i8* %106, i64 0
store i8 0, i8* %107
br label %108
108: ; preds = %105, %96
%109 = load i32, i32* %18
%110 = icmp sge i32 %109, 77
br i1 %110, label %111, label %118
111: ; preds = %108
%112 = load i8*, i8** %27
%113 = load i8*, i8** %17
%114 = getelementptr inbounds i8, i8* %113, i64 76
%115 = call i32 @strncpy(i8* %112, i8* %114, i32 2)
%116 = load i8*, i8** %27
%117 = getelementptr inbounds i8, i8* %116, i64 2
store i8 0, i8* %117
br label %121
118: ; preds = %108
%119 = load i8*, i8** %27
%120 = getelementptr inbounds i8, i8* %119, i64 0
store i8 0, i8* %120
br label %121
121: ; preds = %118, %111
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%5d\00"
define void @get_pdb_fields(i8* %0, i32 %1, i32* %2, i8* %3, i8* %4, i8* nocapture writeonly %5, i8* %6, i8* %7, i8* nocapture writeonly %8, i8* %9, i8* %10, float* %11, float* %12, float* %13, float* %14, float* %15) {
%17 = alloca [6 x i8]
%18 = getelementptr inbounds [6 x i8], [6 x i8]* %17, i64 0, i64 0
%19 = getelementptr inbounds i8, i8* %0, i64 6
%20 = call i32 @strncpy(i8* %18, i8* %19, i32 5)
%21 = getelementptr inbounds [6 x i8], [6 x i8]* %17, i64 0, i64 5
store i8 0, i8* %21
store i32 0, i32* %2
%22 = call i32 @sscanf(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %2)
%23 = getelementptr inbounds i8, i8* %0, i64 12
%24 = call i32 @strncpy(i8* %3, i8* %23, i32 4)
%25 = getelementptr inbounds i8, i8* %3, i64 4
store i8 0, i8* %25
%26 = call i32 @adjust_pdb_field_string(i8* %3)
%27 = getelementptr inbounds i8, i8* %0, i64 16
%28 = call i32 @strncpy(i8* %9, i8* %27, i32 1)
%29 = getelementptr inbounds i8, i8* %9, i64 1
store i8 0, i8* %29
%30 = getelementptr inbounds i8, i8* %0, i64 17
%31 = call i32 @strncpy(i8* %4, i8* %30, i32 4)
%32 = getelementptr inbounds i8, i8* %4, i64 4
store i8 0, i8* %32
%33 = call i32 @adjust_pdb_field_string(i8* %4)
%34 = getelementptr inbounds i8, i8* %0, i64 21
%35 = load i8, i8* %34
store i8 %35, i8* %5
%36 = getelementptr inbounds i8, i8* %5, i64 1
store i8 0, i8* %36
%37 = getelementptr inbounds i8, i8* %0, i64 22
%38 = call i32 @strncpy(i8* %7, i8* %37, i32 4)
%39 = getelementptr inbounds i8, i8* %7, i64 4
store i8 0, i8* %39
%40 = call i32 @adjust_pdb_field_string(i8* %7)
%41 = getelementptr inbounds i8, i8* %0, i64 26
%42 = load i8, i8* %41
store i8 %42, i8* %8
%43 = getelementptr inbounds i8, i8* %8, i64 1
store i8 0, i8* %43
%44 = call i32 @get_pdb_coordinates(i8* %0, float* %11, float* %12, float* %13, float* %14, float* %15)
%45 = icmp sgt i32 %1, 72
br i1 %45, label %47, label %46
46: ; preds = %16
store i8 0, i8* %6
br label %57
47: ; preds = %16
%48 = getelementptr inbounds i8, i8* %0, i64 72
%49 = call i32 @strncpy(i8* %6, i8* %48, i32 4)
%50 = getelementptr inbounds i8, i8* %6, i64 4
store i8 0, i8* %50
%51 = call i32 @adjust_pdb_field_string(i8* %6)
%52 = icmp ugt i32 %1, 76
br i1 %52, label %53, label %57
53: ; preds = %47
%54 = getelementptr inbounds i8, i8* %0, i64 76
%55 = call i32 @strncpy(i8* %10, i8* %54, i32 2)
%56 = getelementptr inbounds i8, i8* %10, i64 2
br label %57
57: ; preds = %47, %46, %53
%58 = phi i8* [ %56, %53 ], [ %10, %46 ], [ %10, %47 ]
store i8 0, i8* %58
ret void
}