#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 */
scalar_t__ atoi(char *);
char *strtok(char *, char *);
int DetermineTotalNumberOfAtoms(char buffer[256]) {
  int TotalNumberOfAtoms = 0;
  char *pointer = strtok(buffer, " ");
  while (pointer != NULL) {
    TotalNumberOfAtoms += atoi(pointer);
    pointer = strtok(NULL, " ");
  }
  return TotalNumberOfAtoms;
}


x86 assembly (clang, -O0):
<DetermineTotalNumberOfAtoms>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xec2(%rip),%rsi
call   1030 <strtok@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1181 <DetermineTotalNumberOfAtoms+0x61>
mov    -0x18(%rbp),%rdi
call   1040 <atoi@plt>
mov    %rax,%rcx
movslq -0xc(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe8d(%rip),%rsi
call   1030 <strtok@plt>
mov    %rax,-0x18(%rbp)
jmp    1147 <DetermineTotalNumberOfAtoms+0x27>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DetermineTotalNumberOfAtoms>:
push   %r14
push   %rbx
push   %rax
lea    0xed5(%rip),%rsi
call   1030 <strtok@plt>
xor    %ebx,%ebx
test   %rax,%rax
je     1159 <DetermineTotalNumberOfAtoms+0x39>
lea    0xec2(%rip),%r14
xchg   %ax,%ax
mov    %rax,%rdi
call   1040 <atoi@plt>
add    %eax,%ebx
xor    %edi,%edi
mov    %r14,%rsi
call   1030 <strtok@plt>
test   %rax,%rax
jne    1140 <DetermineTotalNumberOfAtoms+0x20>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
define i32 @DetermineTotalNumberOfAtoms(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
store i8* %0, i8** %2
store i32 0, i32* %3
%5 = load i8*, i8** %2
%6 = call i8* @strtok(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %6, i8** %4
br label %7
7: ; preds = %10, %1
%8 = load i8*, i8** %4
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %18
10: ; preds = %7
%11 = load i8*, i8** %4
%12 = call i64 @atoi(i8* %11)
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = add nsw i64 %14, %12
%16 = trunc i64 %15 to i32
store i32 %16, i32* %3
%17 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %17, i8** %4
br label %7
18: ; preds = %7
%19 = load i32, i32* %3
ret i32 %19
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
define i32 @DetermineTotalNumberOfAtoms(i8* %0) {
%2 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i8* %2, null
br i1 %3, label %12, label %4
4: ; preds = %1, %4
%5 = phi i8* [ %10, %4 ], [ %2, %1 ]
%6 = phi i32 [ %9, %4 ], [ 0, %1 ]
%7 = tail call i64 @atoi(i8* %5)
%8 = trunc i64 %7 to i32
%9 = add i32 %6, %8
%10 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %4
12: ; preds = %4, %1
%13 = phi i32 [ 0, %1 ], [ %9, %4 ]
ret i32 %13
}