#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*/ __builtin_stwio(unsigned int *, int);
void test_stwio(unsigned int *p1, unsigned int *p2) {
  __builtin_stwio(p1, *p2);
  __builtin_stwio(p2, 0);
  __builtin_stwio(p2 + 1, 0x80000000);
  __builtin_stwio(p2 + 2, 0x7fffffff);
  __builtin_stwio(p2 + 511, 5);
  __builtin_stwio(p2 + 512, 5);
}


x86 assembly (clang, -O0):
<test_stwio>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
call   1030 <__builtin_stwio@plt>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1030 <__builtin_stwio@plt>
mov    -0x10(%rbp),%rdi
add    $0x4,%rdi
mov    $0x80000000,%esi
call   1030 <__builtin_stwio@plt>
mov    -0x10(%rbp),%rdi
add    $0x8,%rdi
mov    $0x7fffffff,%esi
call   1030 <__builtin_stwio@plt>
mov    -0x10(%rbp),%rdi
add    $0x7fc,%rdi
mov    $0x5,%esi
call   1030 <__builtin_stwio@plt>
mov    -0x10(%rbp),%rdi
add    $0x800,%rdi
mov    $0x5,%esi
call   1030 <__builtin_stwio@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_stwio>:
push   %rbx
mov    %rsi,%rbx
mov    (%rsi),%esi
call   1030 <__builtin_stwio@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <__builtin_stwio@plt>
lea    0x4(%rbx),%rdi
mov    $0x80000000,%esi
call   1030 <__builtin_stwio@plt>
lea    0x8(%rbx),%rdi
mov    $0x7fffffff,%esi
call   1030 <__builtin_stwio@plt>
lea    0x7fc(%rbx),%rdi
mov    $0x5,%esi
call   1030 <__builtin_stwio@plt>
add    $0x800,%rbx
mov    %rbx,%rdi
mov    $0x5,%esi
pop    %rbx
jmp    1030 <__builtin_stwio@plt>

LLVM IR (-O0):
define void @test_stwio(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
store i32* %0, i32** %3
store i32* %1, i32** %4
%5 = load i32*, i32** %3
%6 = load i32*, i32** %4
%7 = load i32, i32* %6
%8 = call i32 @__builtin_stwio(i32* %5, i32 %7)
%9 = load i32*, i32** %4
%10 = call i32 @__builtin_stwio(i32* %9, i32 0)
%11 = load i32*, i32** %4
%12 = getelementptr inbounds i32, i32* %11, i64 1
%13 = call i32 @__builtin_stwio(i32* %12, i32 -2147483648)
%14 = load i32*, i32** %4
%15 = getelementptr inbounds i32, i32* %14, i64 2
%16 = call i32 @__builtin_stwio(i32* %15, i32 2147483647)
%17 = load i32*, i32** %4
%18 = getelementptr inbounds i32, i32* %17, i64 511
%19 = call i32 @__builtin_stwio(i32* %18, i32 5)
%20 = load i32*, i32** %4
%21 = getelementptr inbounds i32, i32* %20, i64 512
%22 = call i32 @__builtin_stwio(i32* %21, i32 5)
ret void
}

LLVM IR (-O2):
define void @test_stwio(i32* %0, i32* %1) {
%3 = load i32, i32* %1
%4 = tail call i32 @__builtin_stwio(i32* %0, i32 %3)
%5 = tail call i32 @__builtin_stwio(i32* %1, i32 0)
%6 = getelementptr inbounds i32, i32* %1, i64 1
%7 = tail call i32 @__builtin_stwio(i32* %6, i32 -2147483648)
%8 = getelementptr inbounds i32, i32* %1, i64 2
%9 = tail call i32 @__builtin_stwio(i32* %8, i32 2147483647)
%10 = getelementptr inbounds i32, i32* %1, i64 511
%11 = tail call i32 @__builtin_stwio(i32* %10, i32 5)
%12 = getelementptr inbounds i32, i32* %1, i64 512
%13 = tail call i32 @__builtin_stwio(i32* %12, i32 5)
ret void
}